So over the weekend, I ended up getting some time to finally take a look at WatchTower.
I have been very curious as to how effective WatchTower would be in my environment, and finally, I got to implement it.
If you don't know what WatchTower is, it's a docker container that updates other running containers as updates become available hence the WatchTower name.
To get it up and running is quite simple as well. I used the following docker-compose to get it up and running;
version: '3' services: watchtower: image: containrrr/watchtower restart: always volumes: - /var/run/docker.sock:/var/run/docker.sock - /etc/timezone:/etc/timezone:ro environment: - WATCHTOWER_CLEANUP=true - WATCHTOWER_LABEL_ENABLE=true - WATCHTOWER_INCLUDE_RESTARTING=true labels: - "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 its updates.
Simply just add the following label to your docker-compose YAML file:
labels: - "com.centurylinklabs.watchtower.enable=true"
I’ve added a labels attribute and set the parameter that Watchtower looks for when running its 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.
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, and restarted and the old image removed (as long as it’s not used elsewhere).