docker-compose keeps using old image content

余生长醉 提交于 2020-08-21 12:27:42

问题


We use our gitlab-ci to build fresh images with the latest version of our code. These images are day to day built with the latest tag. We tag images during the release process.

My problem is related to the latest tag. We deploy automatically these images on servers to test our product.

However, on a test server if we pull the latest docker image (verified by its checksum), stop the compose and up it again, we sometime still have the content of the old image (for example a configuration file).

We tried with docker-compose up -d --force-recreate but it doesn't help.

The only way to fix it was: docker-compose down docker system prune -f docker rmi $(docker images -q) docker-compose pull docker-compose up -d

Any better idea ?


回答1:


According to the documentation, you can ignore data from previous volume with this:

docker-compose up -d --force-recreate --renew-anon-volumes

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




回答2:


I just had this problem in dev too. docker-compose up uses an old image even though I have built the latest image. And if I manually run docker run in latest image I can see the new changes. What fixed for me is running:

docker-compose up --build <your-service>.

Hope it helps!




回答3:


The process should be:

docker-compose pull
docker-compose up

If you have volumes, then those will be persistent by design. If you need your volumes to not be persistent, then you may want to reconsider having that data inside a volume, or you'll need to reset the volume on every redeploy with a docker-compose down -v to remove the containers and the volumes.

If you still have issues with this, make sure your install of docker and docker-compose are current.



来源:https://stackoverflow.com/questions/44461035/docker-compose-keeps-using-old-image-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!