Category : Docker Compose Files
Watchtower is a docker container that will update the version of other running containers. You can change the environment settings as required for your installation – see the full documentation for more info.
Create a new directory and save the above file inside it as docker-compose.yml.
Run docker-compose up -d to fetch the image from the docker hub and create your Watchtower instance. By default, Watchtower will check for updates every 24 hours from the moment you start the Watchtower container. You’ll now need to add labels to your docker containers that you’d like to update which is described below.
The above docker-compose file will get Watchtower up and running but in it’s current state it won’t update any of your existing docker containers. The above docker-compose file is safe by default so that it won’t do anything other than update itself – arguably useless, but safe!
To update your other docker containers you need to add a label to their docker-compose file that sets
com.centurylinklabs.watchtower.enable=true. Watchtower will then pick up that label and know that it needs to include that docker container (or service) in it’s updates.
The below is a random docker-compose file that I use to run a database for development work. I’ve added a labels attribute and set the parameter that Watchtower looks for when running it’s update routine. For your containers to be included in Watchtowers update routine you’ll need to add the same labels attribute to ALL of your docker-compose services, just like in the below example – its a simple copy and paste.
Once you’ve added the labels attribute, simply wait for a new image to be released and within 24 hours your container will have been updated, restarted and the old image removed (as long as it’s not used elsewhere).