Score:0

Recreate single docker-compose container with new config

cm flag
Tom

If I make changes to my docker-compose.yml (say, change which host port a container port is exposed on), can I recreate that single container or do I need to restart the whole stack?

docker-compose stop ; docker-compose up will do the job but I want to avoid restarting the rest of the services. I also want to avoid deleting volumes associated with the service that I'm restarting, so docker-compose kill <service> ; docker-compose rm is not an option.

Score:2
in flag

Just run docker-compose up again. Everything that is impacted by your change (container, volume, network, etc.) is going to be recreated, the other containers will stay.

If you want to use newer images, run docker-compose pull beforehand.

Pavel Niedoba avatar
mq flag
I have `env_file: -myenv` in `compose.yml`, changes to that file are ignored by 'docker compose up'
Score:0
mq flag

Sometimes changes to some env file are ignored. Then I do

docker stop mycontainer
docker compose up

this will restart single container plus dependent containers which is what you do. Avoiding restarting dependent containers is bad idea, because mycontainer will come up with different docker ip

having some kind of reload command would be nice

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.