docker-compose up/down just one container

I found this to have the same affect as docker-compose down for a single service:

docker-compose rm -s -v yourService

docker-compose rm

Usage: rm [options] [SERVICE...]

Options:
-s, --stop Stop the containers, if required, before removing
-v Remove any anonymous volumes attached to containers

You can condense all the flags into a single - param: docker-compose rm -sv yourService


I would suggest you check out this excellent thread on stackoverflow.com. The quick answer here to rebuild the single container and restart it is:

docker-compose up -d --build worker

This would be the ideal solution if, for example, your changes involved your Dockerfile and not just docker-compose.ymll


You can use

$ docker-compose -f docker-compose.yml up yourService

to start just yourService and all dependencies required by it.

So if yourService depends on mysql container, the above command would start both the containers.

Tags:

Docker