Artem Belskii
Artem Belskii

Reputation: 31

docker-compose run not last image

When I run

docker-compose -f docker-compose.prod.yml pull
docker-compose -f docker-compose.prod.yml up -d --force-recreate

I have not last image - seems like this some cached image from first run. But wen I run this image from docker via name, like docker run -it repo_url/image_name - all ok. I have try all from topic How to get docker-compose to always re-create containers from fresh images? Also I have try remove this image via docker rmi image_name, but nothing help to me. What it can be?

Upvotes: 1

Views: 212

Answers (1)

Paul Trehiou
Paul Trehiou

Reputation: 537

What is happening

Dockerfile

FROM httpd:latest
COPY index.html /var/www/html/
  1. You run it with a volume : docker run -v my-data:/var/www/html/ since this volume does not exist yet it is created and the content of /var/www/html from the current image is copied into it.
  2. Then you change the file index.html and rebuild your image. A new image is now created.
  3. You run it with the same command. The volume my-data exist so the content of /var/www/html from this new image you just created will not be copied into the volume.
  4. So when you access the front page you will see the old file.

Upvotes: 1

Related Questions