How to rebuild docker container in docker-compose.yml?

yuklia picture yuklia · Apr 27, 2016 · Viewed 322.5k times · Source

There are scope of services which defined in docker-compose.yml. These service have been started. I need to rebuild only one of these and start it without up other services. I run the following commands:

docker-compose up -d # run all services
docker-compose stop nginx # stop only one. but it still running !!!
docker-compose build --no-cache nginx 
docker-compose up -d --no-deps # link nginx to other services

At the end i got old nginx container. By the way docker-compose doesn't kill all running containers !

Answer

denov picture denov · Mar 10, 2017

docker-compose up

$ docker-compose up -d --no-deps --build <service_name>

--no-deps - Don't start linked services.

--build - Build images before starting containers.