Skip to content

Docker Ansible

willhallonline/docker-ansible is the core repository for the willhallonline/ansible Docker image family.

It provides Ansible inside Docker containers for Alpine, Ubuntu, Rocky Linux, and Debian. The images include ansible-core, ansible, and ansible-lint so that local development and CI jobs can use the same packaged toolchain.

Short description

Ansible inside Docker containers: Alpine, Ubuntu, Rocky Linux, and Debian with active Ansible core streams 2.18 through 2.21. The current upstream release is v6.4.9 (commit 32ea135, 2026-09-13).

Resource Link
Source repository https://github.com/willhallonline/docker-ansible
Docker Hub https://hub.docker.com/r/willhallonline/ansible
Maintainer Will Hall
Changelog https://github.com/willhallonline/docker-ansible/blob/main/CHANGELOG.md
Contributing https://github.com/willhallonline/docker-ansible/blob/main/CONTRIBUTING.md
Security policy https://github.com/willhallonline/docker-ansible/blob/main/SECURITY.md
License https://github.com/willhallonline/docker-ansible/blob/main/LICENSE

What is included

Each current image is intended to provide a ready-to-run Ansible environment:

  • ansible-core
  • ansible
  • ansible-lint
  • Python and operating-system packages required by the chosen image variant
  • A predictable Docker entry point for running Ansible commands

Current images run as the non-root ansible user (UID/GID 1000) by default. Mount SSH keys and known_hosts under /home/ansible/.ssh/. Use --user root only when a build or diagnostic step specifically needs root. The default command is ansible-playbook --version, and the healthcheck runs ansible --version every 30 seconds (5-second timeout, 5-second start period, three retries).

docker run --rm willhallonline/ansible:latest ansible --version
docker run --rm willhallonline/ansible:latest ansible-lint --version

Supported Ansible versions

Current versions published by the project include:

Ansible version Notes
2.21.4 Current newer Ansible release line.
2.20.9 Current stable Ansible release line.
2.19.13 Supported recent release line.
2.18.19 Supported release line.

Older does not mean maintained

Ansible core streams 2.9 through 2.17 are outside the active matrix and unmaintained. Do not assume that historical definitions or tags are published; verify any legacy dependency against the upstream registry.

Repository layout

The repository is organised around image definitions and support files.

Path Purpose
ansible-core/<os>/Dockerfile Dockerfiles for current image variants.
ansible-core/alpine-3.21 - ansible-core/alpine-3.24 Alpine-based image variants.
ansible-core/debian-bookworm Debian Bookworm image variant.
ansible-core/debian-bookworm-slim Slim Debian Bookworm variant.
ansible-core/debian-trixie Debian Trixie image variant.
ansible-core/debian-trixie-slim Slim Debian Trixie variant.
ansible-core/rockylinux-10 Rocky Linux 10 image variant.
ansible-core/ubuntu-24.04 Ubuntu 24.04 image variant.
ansible-core/ubuntu-26.04 Ubuntu 26.04 image variant.
testing-utils/ Helpers used by testing workflows.
.github/ GitHub workflows and automation.
.gitlab-ci.yml GitLab CI configuration.
renovate.json Renovate dependency update configuration.
CHANGELOG.md Upstream change history.
CONTRIBUTING.md Contribution guidance.
SECURITY.md Security reporting guidance.
LICENSE MIT license.

Base operating systems

The project publishes image variants for multiple Linux distributions so you can choose the runtime that best matches your playbooks and dependencies.

Family Example variants When to consider it
Alpine alpine-3.21 through alpine-3.24 Small images and fast pulls.
Debian debian-bookworm, debian-trixie Broad Python package compatibility.
Debian slim debian-bookworm-slim, debian-trixie-slim Debian compatibility with a smaller footprint.
Ubuntu ubuntu-22.04, ubuntu-24.04, ubuntu-26.04 Familiar apt-based CI and enterprise workflows.
Rocky Linux rockylinux-10 RHEL-family compatibility testing.

Alpine versus glibc distributions

Alpine uses musl libc. Some Python packages with native extensions may need build dependencies or may be easier to install on Debian or Ubuntu variants.

Python comes from each distribution's packages rather than one globally pinned Python release. The images use uv/uvx for Python tooling and package installation.

Image tags and platforms

Tags are generated from the core version and operating system, for example 2.21-alpine-3.24 or 2.21-debian-trixie; full core patch tags are also published. Current builds generally target linux/amd64 and linux/arm64, but manifests are tag-specific: 2.21-ubuntu-24.04 is currently AMD64-only. There are no ARMv7/32-bit ARM builds.

Basic usage

Mount your project into the container and run commands from the mounted path. Many examples use /ansible as the working directory.

docker run --rm   -v "$PWD:/ansible"   -w /ansible   willhallonline/ansible:latest   ansible-playbook site.yml

For localhost-only playbooks, use a local connection:

- hosts: localhost
  connection: local
  gather_facts: false
  tasks:
    - debug:
        msg: "Hello from Docker Ansible"

Then run:

docker run --rm   -v "$PWD:/ansible"   -w /ansible   willhallonline/ansible:latest   ansible-playbook -i localhost, playbook.yml

Automation and rebuilds

The upstream repository includes Renovate configuration for automated dependency updates. Images are rebuilt regularly as the project tracks Ansible, Python, and base-image updates.

Repeatability

Regular rebuilds are useful for security and dependency freshness. Production jobs should still pin tags, and high-assurance environments should pin image digests.