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 !
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.
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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With