1

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?

Community
  • 1
  • 1
  • What is the content of the compose file ? Maybe there is a specific version of your image specified in it. – Paul Trehiou Dec 19 '16 at 09:47
  • php: image: registry.url/content-php:latest links: - postgres volumes: - datadir:/var/www/html/ – Artem Belskii Dec 19 '16 at 09:59
  • It should use the latest version. Are you sure the containers are effectively recreated ? You can try to delete the containers manually and it should use the latest version of the image when you start `docker-compose up`. – Paul Trehiou Dec 19 '16 at 10:02
  • yes, I already try `docker-compose pull docker-compose kill docker-compose rm -f docker-compose up -d --force-recreate` but no effect – Artem Belskii Dec 19 '16 at 10:08
  • Is your new image shipping new content in the folder `/var/www/html/` ? If this is the case this will not be reflected when you recreate the container because the volume will not be recreated. EDIT : You can try `docker-compose -f docker-compose.prod.yml down --rmi all -v` which will stop and remove the containers, images and volumes – Paul Trehiou Dec 19 '16 at 10:12
  • 1
    You my hero! This help to me! – Artem Belskii Dec 19 '16 at 10:40
  • I really use ADD . /var/www/html in my dokerfile. but for other images I newer see something like this before – Artem Belskii Dec 19 '16 at 10:43
  • this problem relevant only for /var/www/html/ or for all folders? and Paul, please post you answer as comment, I'll mark it as answer. – Artem Belskii Dec 19 '16 at 10:45
  • You should edit your question a bit with the informations in the comments (like the volumes) – Paul Trehiou Dec 20 '16 at 11:22

1 Answers1

1

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.
Paul Trehiou
  • 537
  • 5
  • 18