Automatic Docker image update checker/updater.
Educational example only. Review every volume path, port, and credential before you run this. Do not copy production secrets into your wiki or git repo.
_shared/.env for non-secrets, _shared/.secret for credentialsmkdir -p /path/to/docker/stacks/watchtower
cd /path/to/docker/stacks/watchtower
# paste compose.yaml below, then:
docker compose pull
docker compose up -d
services:
watchtower:
image: containrrr/watchtower:latest
container_name: watchtower
hostname: watchtower
env_file:
- /path/to/docker/stacks/_shared/.env
- /path/to/docker/stacks/_shared/.secret
environment:
- WATCHTOWER_DISABLE_CONTAINERS=immich_postgres,immich_redis
- WATCHTOWER_SCHEDULE=0 2 * * *
- WATCHTOWER_CLEANUP=true
#- WATCHTOWER_NOTIFICATION_URL= comes from _shared/.secret via env_file
- WATCHTOWER_NOTIFICATION_EMAIL_DELAY=2
- WATCHTOWER_NOTIFICATIONS_HOSTNAME=YOUR_HOST
- WATCHTOWER_NO_STARTUP_MESSAGE=true
# WATCHTOWER_HTTP_API_TOKEN comes from _shared/.secret via env_file
- WATCHTOWER_HTTP_API_UPDATE=true
- WATCHTOWER_HTTP_API_PERIODIC_POLLS=true
- WATCHTOWER_TIMEOUT=30s
- DOCKER_API_VERSION=1.44
logging:
driver: json-file
options:
max-file: ${DOCKERLOGGING_MAXFILE:-10} # Max number of log files
max-size: ${DOCKERLOGGING_MAXSIZE:-200k} # Max file size
volumes:
- /var/run/docker.sock:/var/run/docker.sock
restart: always
_shared/.secret.