Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose keeps using old image content

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 ?

like image 253
David Avatar asked Jun 09 '17 15:06

David


People also ask

How do I get rid of dangling docker images?

If we do not want to find dangling images and remove them one by one, we can use the docker image prune command. This command removes all dangling images. If we also want to remove unused images, we can use the -a flag. The command will return the list of image IDs that were removed and the space that was freed.

How do I stop docker from using images?

To stop a container you use the docker stop command and pass the name of the container and the number of seconds before a container is killed. The default number of seconds the command will wait before the killing is 10 seconds.

Does docker compose build a new image?

Docker-compose build, will build individual images, by going into individual service entry in docker-compose. yml. With docker images, command, we can see all the individual images being saved as well.

How do I get rid of unused docker volumes?

Volumes are removed using the docker volume rm command. You can also use the docker volume prune command.


1 Answers

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/

like image 71
Sika Avatar answered Oct 05 '22 13:10

Sika