Watchtower supports the following features:#
- Automatically pull images and update containers.
- Configure email notifications.
- Schedule container update tasks.
- Create a new folder
First, create a watchtower folder (name it as you like) in any location to store the docker-compose.yaml file; just place one YAML file in it!
Create a docker-compose.yaml file#
vim docker-compose.yaml
Version with email notifications#
Pay attention to the comments for email notification configuration
version: '3' # docker-compose version can be commented
services:
watchtower:
image: containrrr/watchtower:latest
container_name: watchtower
environment:
- TZ=Asia/Shanghai # Time zone
- WATCHTOWER_NOTIFICATIONS=email # Enable email notifications
- WATCHTOWER_NOTIFICATION_EMAIL_FROM=xxxx@qq.com # Sender's email
- WATCHTOWER_NOTIFICATION_EMAIL_TO=xxxx@qq.com # Recipient's email
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER=smtp.qq.com # Email server address
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT=587 # Email server port
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER=xxxx@qq.com # Email
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=atzzz.com # Email server password
- WATCHTOWER_NOTIFICATION_EMAIL_DELAY=30 # Email notification delay, in seconds
volumes:
- /var/run/docker.sock:/var/run/docker.sock # Access Docker daemon
restart: unless-stopped # Automatically restart the container
command: --schedule "23 5 * * *" --cleanup # Update at 3 AM daily, remove old images, and send notifications
Version without email notifications#
version: '3' # docker-compose version can be commented
services:
watchtower:
image: containrrr/watchtower:latest
container_name: watchtower
environment:
- TZ=Asia/Shanghai # Time zone
volumes:
- /var/run/docker.sock:/var/run/docker.sock # Access Docker daemon
restart: unless-stopped # Automatically restart the container
command: --schedule "23 5 * * *" --cleanup # Update at 3 AM daily, remove old images
Start the image#
docker-compose up -d
Video tutorial on YouTube#
For more configuration files, you can check the official documentation
https://containrrr.dev/watchtower/arguments/