Ansible role for deploying a docker website using port or traefik routing https://www.docker.com/
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Conrad dad5bb9da0
All checks were successful
Lint + Tag / format (push) Successful in 1m21s
Lint + Tag / tag (push) Successful in 1m6s
feat: added domains list, update schedule applies right away
2026-10-11 22:13:37 +07:00
.forgejo/workflows feat: initial version 2026-10-11 21:50:47 +07:00
defaults feat: added domains list, update schedule applies right away 2026-10-11 22:13:37 +07:00
meta feat: initial version 2026-10-11 21:50:47 +07:00
tasks feat: added domains list, update schedule applies right away 2026-10-11 22:13:37 +07:00
templates feat: added domains list, update schedule applies right away 2026-10-11 22:13:37 +07:00
.gitignore feat: initial version 2026-10-11 21:50:47 +07:00
CHANGELOG.md feat: added domains list, update schedule applies right away 2026-10-11 22:13:37 +07:00
LICENSE feat: initial version 2026-10-11 21:50:47 +07:00
README.md feat: added domains list, update schedule applies right away 2026-10-11 22:13:37 +07:00

Docker Website

Runs one website container from an image, published on a host port and/or through Traefik. Optionally pulls the image daily and recreates the container when the tag points to a new image.

Variables

Variable Default Description
docker_website_name ~ Required. Compose project, container and unit name ([a-z0-9_-]).
docker_website_image ~ Required. Image incl. tag.
docker_website_container_port 80 Port inside the container.
docker_website_domains [] Domains served through Traefik (traefik_web, websecure).
docker_website_traefik_certresolver default Traefik certificate resolver.
docker_website_port ~ Host port to publish on. This, the domains, or both.
docker_website_env {} Environment variables.
docker_website_auto_update true Scheduled docker compose pull + up -d (systemd timer <name>-update).
docker_website_auto_update_schedule *-*-* 04:00:00 systemd OnCalendar of that timer, e.g. hourly.
docker_website_docker_path /docker/<name> Compose file.
docker_website_uninstall false Removes container, timer and compose directory.

Usage

- hosts: web01
  roles:
    - role: docker_website
      vars:
        docker_website_name: website
        docker_website_image: ghcr.io/example/site:latest
        docker_website_domains: [example.com, www.example.com]

Several websites on one host: include the role once per site with a different docker_website_name.

Updates

Auto-update follows the tag: latest or 1 move with new releases and get picked up on the next timer run; a fixed tag like 1.4.2 never changes. A deploy (Ansible run) also pulls. Run an update by hand with systemctl start <name>-update.

Private registries: log in on the host once (docker login).