Docker compose ignores changes in Dockerfile

When: I have CMD/command specified in both Dockerfile and docker-compose.yml. I run docker-compose up. Then i decide to delete command line in docker-compose.yml and meanwhile change the contents of CMD line in Dockerfile. Now i run docker-compose. It usues CMD line from old version because it uses imge it built before and don’t update it. I have to manually delete old image and run everything again in order for it to work.

If this is intended behavior then it would be great if docker at gave at least a worning that it will not update the image.


Yes this is intended, if you want to force a rebuild of the image before start, you can use:

docker-compose up -d --build
1 Like

Thanks for response

I would want it to check if the Dockerfile is changes and at least give me warning or choice. If i now change the Dockerfile the result depends on whether i deleted old image in meanwhile or not, which is unpredictable from common user point of view.

Why do you need to delete it?
If you use above command it will build the image if there is changes and start the container with the new image.