Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker compose to always deploy using latest image

I have searched around and found some similar questions, but no answer seemed to clarify completely.

Scenario: Newer images keep getting pushed to the concerned Docker registry. I want to use docker-compose to always pull the latest image from the registry and then replace the existing running container on the Docker host with a new container deployed from that latest image.

Is just executing 'docker-compose up -d' enough? Or do I need to do a 'docker-compose pull' or any other step before that?

like image 321
Rama Avatar asked Aug 22 '16 13:08

Rama


People also ask

Does docker compose up pull latest image?

The docker-compose pull command above pulls the latest versions of the images and then the docker-compose up -d command re-creates the containers from that images and starts them in a background.

Does docker compose automatically pull images?

The docker-compose spec says: pull_policy defines the decisions Compose implementations will make when it starts to pull images. always: always pull.

Does docker compose auto update?

In this tutorial, you will use Watchtower with both Docker's run command and Docker Compose to automatically update a Docker image. Both methods are functionally the same in creating a container running Watchtower, then pointing it towards a container you wish to keep automatically updated.


1 Answers

You won't pull new service images just running this command:

docker-compose up -d

If you need to always check for a newer image and use it this command should work for you:

docker-compose pull && docker-compose up -d
like image 160
TopperH Avatar answered Sep 23 '22 15:09

TopperH