A Ubuntu Docker image with systemd, to be used as a platform of Ansible Molecule (docker driver).
778
molecule-ubuntuInspired by geerlingguy/docker-ubuntu2404-ansible by Jeff Geerling (MIT License). This image is an update for the latest Ubuntu releases.
An Ubuntu Docker image with systemd, to be used as a platform of Molecule (docker driver) tests of Ansible roles that manage services.
systemd-sysv, sudo, procps, iproute2 and dbus,ca-certificates: the TLS trust store of any real host, so HTTPS downloads (get_url, uri) work out of the box,cron, enabled at boot, for roles that manage crontabs (cron module, /etc/cron.d),python3 and python3-apt: what Ansible needs on a target (the apt module). No Ansible in the image: Molecule runs on the controller and drives the container,multiarch with support of amd64 and arm64,SBOM) attestation,| Tag | Meaning |
|---|---|
noble, resolute | The last build of this Ubuntu codename (Ubuntu 24.04 and 26.04 LTS). Recommended: pin one in molecule.yml. |
<codename>-NNN | An immutable build of a codename (resolute-001, resolute-002...), to reproduce a given run. |
latest | The latest Ubuntu LTS (the codename of ubuntu:latest). It moves automatically to the new codename when Ubuntu releases a new LTS, once that codename is built. |
Prefer the codename tag over latest in your molecule.yml: latest changes the Ubuntu version under your tests when Ubuntu publishes a new LTS.
platforms:
- name: instance
image: jfxs/molecule-ubuntu:resolute
pre_build_image: true
command: /usr/lib/systemd/systemd
cgroupns_mode: host
privileged: true
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
Without Molecule:
docker run --detach --privileged --cgroupns=host --tmpfs /run --tmpfs /tmp \
--volume /sys/fs/cgroup:/sys/fs/cgroup:rw jfxs/molecule-ubuntu:resolute
This image is for isolated tests, not for production.
task install-templates # fetch the task templates (first time)
task 00:10-build-local C=noble # build molecule-ubuntu:noble (default codename: resolute)
task 00:20-test-local IMG=molecule-ubuntu:noble
Without task: docker build --build-arg VERSION=noble -t molecule-ubuntu:noble . then tests/acceptance.sh molecule-ubuntu:noble.
tests/acceptance.sh starts the container and checks that systemd is running, that python3 imports apt, that ca-certificates is installed and an HTTPS download works, that cron is installed and active at boot, and that a service (cron) can be stopped and started.
Add a base stage (FROM ubuntu:<codename>@sha256:... AS base-<codename>) to the Dockerfile, an inclusion of the docker component and a matrix entry in .gitlab-ci.yml. tests/check_ci.sh verifies that the codenames agree everywhere (task 00:30-test-scripts, also run by the scripts:test CI job).
Last published tags: resolute-003, resolute.
Dockerhub Overview page has the details of the last published image.
The image is signed with Cosign and carries a SBOM attestation:
cosign verify --key cosign.pub $IMAGE_URI
cosign verify-attestation --key cosign.pub --type spdxjson $IMAGE_URI | jq '.payload | @base64d | fromjson | .predicate'
This program is free software: you can redistribute it and/or modify it under the terms of the MIT License (MIT). See the LICENSE for details.
docker pull jfxs/molecule-ubuntu:latest