Add docker-compose configuration for watchtower service

This commit is contained in:
2025-11-21 19:36:08 -05:00
parent 2f00b2b0a4
commit be2268d6a6

View File

@@ -0,0 +1,48 @@
version: "3"
services:
watchtower:
image: containrrr/watchtower
container_name: watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /etc/localtime:/etc/localtime:ro
environment:
WATCHTOWER_SCHEDULE: 0 0 1 * * *
#TZ: America/New_York
WATCHTOWER_CLEANUP: "true"
WATCHTOWER_DEBUG: "true"
WATCHTOWER_NOTIFICATION_REPORT: "true"
WATCHTOWER_NOTIFICATION_URL: >
discord://YourDiscordBotToken@YourDiscordID
generic://discord.com/api/webhooks/YourDiscordID/YourDiscordBotToken
# slack://watchtower@xoxe.xoxp-1-Mi0yLTUTExNDExNzAtNTMzAwNzYzOsdfDUxOC01ODM5NTg1MTY1ODkxLTU4NDIaxMjUwNzY0NjgtBiNTkwZTY1ZTg5NGE4MGQzOWIwxZThkNjkwMTE0NzE3NdWM0YzU0MmYzZjeg4MTE5YzNmMDY3YmMyNmNflZTI2ZA@C05Q939CGTZ
WATCHTOWER_NOTIFICATION_TEMPLATE: |
{{- if .Report -}}
{{- with .Report -}}
{{len .Scanned}} Scanned, {{len .Updated}} Updated, {{len .Failed}} Failed
{{- range .Updated}}
- {{.Name}} ({{.ImageName}}): {{.CurrentImageID.ShortID}} updated to {{.LatestImageID.ShortID}}
{{- end -}}
{{- range .Fresh}}
- {{.Name}} ({{.ImageName}}): {{.State}}
{{- end -}}
{{- range .Skipped}}
- {{.Name}} ({{.ImageName}}): {{.State}}: {{.Error}}
{{- end -}}
{{- range .Failed}}
- {{.Name}} ({{.ImageName}}): {{.State}}: {{.Error}}
{{- end -}}
{{- end -}}
{{- else -}}
{{range .Entries -}}{{.Message}}{{"\n"}}{{- end -}}
{{- end -}}
restart: always
stdin_open: true # to attach to containers
tty: true # also used to attach to containers
# network_mode: service:wireguard # To run through vpn service container, in turn UI port must be forwarded inside vpn. No local access unless otherwise defined
networks: # Specify network for container
- homelab
networks: # I don't know why but you have to specify the network 2x. In service, and in this tag area..
homelab:
external: true # This option causes compose to join the above network instead of making a _default one (supposedly)