Here is my docker-compose file for the watchtower container. It auto-updates other containers on the host, including itself (but that often fails for some reason). It uses a pre-configured GMail-adress to send notification mails.
version: "3"
services:
watchtower:
image: containrrr/watchtower
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 8844:8080
container_name: watchtower1
environment:
- WATCHTOWER_HTTP_API_TOKEN=userandomstring
- TZ=Europe/Berlin
- WATCHTOWER_CLEANUP=true
- WATCHTOWER_HTTP_API_UPDATE=true
- WATCHTOWER_HTTP_API_PERIODIC_POLLS=true
- WATCHTOWER_HTTP_API_METRICS=true
- WATCHTOWER_NOTIFICATIONS=email
- WATCHTOWER_NOTIFICATION_EMAIL_FROM=sender@mailadre.ss
- WATCHTOWER_NOTIFICATION_EMAIL_TO=target@mailadre.ss
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER=smtp.gmail.com
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT=587
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER=sender@mailadre.ss
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=secretkey # use an app password for this!
- WATCHTOWER_NOTIFICATION_EMAIL_DELAY=2
- WATCHTOWER_SCHEDULE=0 15 3 * * *
hostname: "hostname"
Code language: YAML (yaml)
The WATCHTOWER_SCHEDULE env variable lets watchtower check for updates every day at 03:15.
Set the hostname to have a readable hostname in e-mail notifications.