Watchtower is a Docker container that automatically updates your running containers whenever a new image is available. It checks Docker Hub or your image registry periodically and applies updates safely. This ensures your services stay up to date without manual intervention. It’s configurable to ignore specific containers or trigger scripts after updates. A must-have tool for automating container maintenance.
Setup
CRON timings
Either I use a one hour schedule 0 0 * * * or a sunday 8AM schedule 0 0 8 ? * SUN. There is also the option WATCHTOWER_MONITOR_ONLY that I can enable or disalbe with a simple boolean value to controll if I auto install the updates or not.
docker-compose.yaml (email)
version: "3"
networks:
docker_net:
external: true
services:
watchtower:
image: nickfedor/watchtower
container_name: watchtower
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /etc/localtime:/etc/localtime:ro
environment:
WATCHTOWER_MONITOR_ONLY: true
WATCHTOWER_SCHEDULE: "0 0 8 ? * SUN"
WATCHTOWER_CLEANUP: true
WATCHTOWER_NOTIFICATION_EMAIL_FROM: $FROM_EMAIL
WATCHTOWER_NOTIFICATION_EMAIL_TO: $TO_EMAIL
WATCHTOWER_NOTIFICATION_EMAIL_SERVER: smtp.gmail.com
WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT: 587
WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER: $FROM_EMAIL
WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD: $GMAIL_APP_PASSWORD
WATCHTOWER_NOTIFICATION_EMAIL_DELAY: 30
WATCHTOWER_NOTIFICATIONS: email
networks:
- docker_net
docker-compose.yaml (discord webhook)
version: "3"
networks:
docker_net:
external: true
services:
watchtower:
image: nickfedor/watchtower
container_name: watchtower
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /etc/localtime:/etc/localtime:ro
environment:
WATCHTOWER_MONITOR_ONLY: true
WATCHTOWER_SCHEDULE: "0 0 8 ? * SUN"
WATCHTOWER_CLEANUP: true
WATCHTOWER_NOTIFICATIONS: slack
WATCHTOWER_NOTIFICATION_SLACK_HOOK_URL: $DISCORD_WEBHOOK_URL # add '/slack' at the end
networks:
- docker_net