Docker Compose conveniently manages containers but cannot automatically update images. With so many images, you can’t manually update each one. Fortunately, Watchtower solves this. Recent GitHub commits are from two years ago, showing the code is stable enough to use with confidence.
Installation
Installation is very simple. Here’s the compose file:
services:
watchtower:
image: containrrr/watchtower
container_name: watchtower
restart: unless-stopped
environment:
- TZ=America/Toronto
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command:
--interval 86400 --label-enable --cleanup
labels:
- "com.centurylinklabs.watchtower.enable=false"
Usage
Usage is very simple. Add these two lines to the compose of any image you want to auto-update. Watchtower accesses docker.sock, scans for images needing updates, and if true is found, automatically downloads the new image and deletes the old one. The interval in the compose’s command is the update check frequency. 86400 means check once daily. Everything is seamless after configuration.
labels:
- "com.centurylinklabs.watchtower.enable=true"