Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 !

like image 689
yuklia Avatar asked Apr 27 '16 08:04

yuklia


People also ask

Does docker compose rebuild?

You can also do docker-compose up --build to force a rebuild. Also worth noting that even if you build every time, Docker's built in cache means the image will only be rebuilt if you change the Dockerfile or any files that you are COPYing. This does NOT force a rebuild, at least not when no files have changed.

Do I need to rebuild docker?

You don't need to rebuild your Docker image in development for each tiny code change. If you mount your code into your dev container, you don't have to build a new image on every code change and iterate faster. It's a great feeling when you make changes and see the results right away!


1 Answers

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.

like image 72
denov Avatar answered Sep 18 '22 17:09

denov