Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

update docker-compose, do I need to re-build image

Tags:

I have my containers running with docker-compose.yml configuration. After that, if I updated my docker-compose.yml file, do I need to rebuild the image or is it fine just restart the containers to have the updated configuration being applied?

like image 543
Leem Avatar asked Aug 05 '19 07:08

Leem


People also ask

Do I have to rebuild docker image?

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!

Does Docker compose up rebuild?

If you change a service's Dockerfile or the contents of its build directory, run docker compose build to rebuild it.

Does Docker compose update images?

Docker Compose has a built-in pull command that will pull updated versions of all the images in your stack.


1 Answers

if the changes is only in docker-compose but not Dockerfile, then you do not need to re-build the image , however you need to make sure that compose is aware of the changes.

From the Docs using docker-compiose restart:

If you make changes to your docker-compose.yml configuration these changes are not reflected after running this command.

Source

the best way is to use --force-recreate , see more this

if the change is in Dockerfile , then yes you need to rebuild the image.

like image 69
LinPy Avatar answered Sep 30 '22 21:09

LinPy