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?
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!
If you change a service's Dockerfile or the contents of its build directory, run docker compose build to rebuild it.
Docker Compose has a built-in pull command that will pull updated versions of all the images in your stack.
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.
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