Dockerfile and docker-compose not updating with new instructions

It seems that when using the docker-compose command it saves an intermediate container that it doesnt show you and constantly reruns that never updating it correctly. Sadly the documentation regarding something like this is poor. The way to fix this is to build it first with no cache and then up it like so

docker-compose build --no-cache
docker-compose up -d

I had the same issue and a one liner that does it for me is :

docker-compose up --build --remove-orphans --force-recreate

  • --build does the biggest part of the job and triggers the build.
  • --remove-orphans is useful if you have changed the name of one of your services. Otherwise, you might have a warning leftover telling you about the old, now wrongly named service dangling around.
  • --force-recreate is a little drastic but will force the recreation of the containers.

Reference: https://docs.docker.com/compose/reference/up/

Warning I could do this on my project because I was toying around with really small container images. Recreating everything, everytime, could take significant time depending on your situation.