Reputation: 86957
I have a docker-compose.yml
file with a few services declared within.
When I type docker-compose up
they all start.
Now, I wish to fix just one of them. I usually then docker-compose down
which stops all of them. Instead, I'm hoping to just pull down the one service I need to fix, fix it (build/compile/etc) and then start up that single Docker image.
So is there a way I can do this instead of doing:
docker-compose down
(all services stop)docker-compose up --build
(all services compile/build/ ... )Upvotes: 0
Views: 143
Reputation: 546
We normally go with:
docker-compose stop servicename
docker-compose rm servicename
and then:
docker-compose up -d servicename
Upvotes: 1
Reputation: 26947
You re-build the images and do a docker-compose up
, which will automatically detect the the image is updated and recreate the service. Down side of building an images while the container from that image is running is that it will leave a none image, since docker won't delete image. You could overcome by removing the container from that image before hand by either one of these commands.
docker rm -vf <container-name>
docker rm -vr <container-id>
If that is inconvenient for you could delete the none
images afterwards by,
docker rmi <image-id>
Also, if you have multiple none
images hanging, you could remove all by,
docker images -q --filter "dangling=true" | xargs docker rmi -f
Upvotes: 1