Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-21 22:49:33 +00:00
.forgejo/workflows feat: initial watchtower deployment 2026-10-22 00:48:37 +02:00
defaults feat: initial watchtower deployment 2026-10-22 00:48:37 +02:00
meta feat: initial watchtower deployment 2026-10-22 00:48:37 +02:00
tasks feat: initial watchtower deployment 2026-10-22 00:48:37 +02:00
templates feat: initial watchtower deployment 2026-10-22 00:48:37 +02:00
CHANGELOG.md feat: initial watchtower deployment 2026-10-22 00:48:37 +02:00
README.md Prettified Code! 2026-10-21 22:49:33 +00:00

Watchtower

Deploys Watchtower (the maintained nickfedor/watchtower fork) via Docker Compose. It watches running containers and, when their image tag has a newer build in the registry, pulls it and recreates the container — the "deploy by pushing an image" setup for apps that track a moving tag like :latest.

Requirements

  • Docker
  • community.docker Ansible collection (>=5.2.0)

Variables

Variable Default Description
watchtower_instance watchtower Unique instance name. Used as Compose project name and container name.
watchtower_docker_path /docker/watchtower Host path for the Compose file.
watchtower_image nickfedor/watchtower Watchtower image.
watchtower_version 1.23.1 Watchtower image tag. Pin to a specific version in production.
watchtower_interval 30 Seconds between image checks.
watchtower_label_enable true Only update containers labelled com.centurylinklabs.watchtower.enable=true.
watchtower_cleanup true Remove the old image after an update.
watchtower_rolling_restart true Restart updated containers one by one.
watchtower_lifecycle_hooks true Run pre/post-update commands declared via container labels.
watchtower_timezone Europe/Berlin Container timezone.
watchtower_registries [] Private registries to log in to (registry, username, password), shared with the host's root docker.
watchtower_extra_args [] Extra command line arguments (e.g. notifications).
watchtower_extra_env {} Extra environment variables.
watchtower_uninstall false Stops and removes the container and the compose directory.

Usage

watchtower_registries:
  - registry: ghcr.io
    username: someone
    password: "{{ vault_ghcr_token }}"

Then opt containers in with the label:

labels:
  - "com.centurylinklabs.watchtower.enable=true"

Notes

  • Opt-in only. With watchtower_label_enable: true (the default) Watchtower only touches labelled containers. Never label containers whose tag must not move under a running database (e.g. postgres:17-alpine), and keep this on unless every container on the host should auto-update.
  • Registry logins are host-wide. watchtower_registries logs the host's root user in (/root/.docker/config.json), which is mounted read-only into the container. The same login lets docker compose pull those images on the first deploy, so put the role before the playbooks that start them.
  • No database migrations. Watchtower only recreates containers. Apps whose image runs its own migrations on start (or doesn't need any) are fine; for others, keep them on pinned tags instead.