Skip to content

trfore/docker-ubuntu2204-systemd

Repository files navigation

docker-ubuntu2204-systemd

CI CD

A minimal systemd enabled Ubuntu 22.04 Docker image for testing Ansible roles with Molecule.

NOTE: This image does NOT contain Ansible tooling, e.g. ansible-core or yamllint. Thus, the use case is as target host for Ansible controllers or within the Molecule create/converge/test cycle.

Docker Pull Command

docker pull trfore/docker-ubuntu2204-systemd

How to Build

This image is built on Docker Hub automatically any time the upstream OS image is rebuilt, and any time a commit is made or merged to the main branch. But if you need to build the image on your own locally, do the following:

  1. Install docker
  2. Clone the repo, git clone https://github.com/trfore/docker-ubuntu2204-systemd.git
  3. cd into the directory
  4. Run docker build --tag trfore/docker-ubuntu2204-systemd .

How to Use

Within Molecule Scenario

  • Add the following code to your molecule scenario file, e.g. molecule/default/molecule.yml.

    platforms:
      - name: instance
        image: trfore/docker-${MOLECULE_DISTRO:-debian10}-systemd:latest
        tmpfs:
          - /run
          - /tmp
        volumes:
          - /sys/fs/cgroup:/sys/fs/cgroup:rw
        cgroupns_mode: host
        privileged: true
        pre_build_image: true

Interactively Using Docker

  • Install docker

  • Build an image locally (see above) or pull from Docker Hub: docker pull trfore/docker-ubuntu2204-systemd:latest

  • On Docker with Cgroup V1 (e.g. Ubuntu 20.04), run a container from the image:

    docker run -d -it --name ubuntu2204-systemd --privileged --cgroupns=host --tmpfs=/run --tmpfs=/tmp --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro trfore/docker-ubuntu2204-systemd:latest
  • On Docker with Cgroup V2 (e.g. Ubuntu 22.04), run a container from the image:

    docker run -d -it --name ubuntu2204-systemd --privileged --cgroupns=host --tmpfs=/run --tmpfs=/tmp --volume=/sys/fs/cgroup:/sys/fs/cgroup:rw trfore/docker-ubuntu2204-systemd:latest
  • Use it, ex:

    docker exec -it ubuntu2204-systemd /bin/bash

Using Podman

  • Podman defaults to running containers in systemd mode, --systemd=true, and will mount the required tmpfs and cgroup filesystem. See Podman Docs: Commands run --systemd for details.

    podman run -d -it --name ubuntu2204-systemd docker.io/trfore/docker-ubuntu2204-systemd:latest

Additional Images

Base OS Github Docker Hub
CentOS Stream 8 docker-centos8-systemd trfore/docker-centos8-systemd
CentOS Stream 9 docker-centos9-systemd trfore/docker-centos9-systemd
Debian 10 docker-debian10-systemd trfore/docker-debian10-systemd
Debian 11 docker-debian11-systemd trfore/docker-debian11-systemd
Debian 12 docker-debian12-systemd trfore/docker-debian12-systemd
Ubuntu 20.04 docker-ubuntu2004-systemd trfore/docker-ubuntu2004-systemd
Ubuntu 22.04 docker-ubuntu2204-systemd trfore/docker-ubuntu2204-systemd
Ubuntu 24.04 docker-ubuntu2404-systemd trfore/docker-ubuntu2404-systemd

Maintainers

Taylor Fore (https://github.com/trfore)

Acknowledgements

Inspired by Jeff Geerling's (@geerlingguy), CentOS 8, Debian 10/11, and Ubuntu 20/22 docker images for ansible, geerlingguy/docker-*-ansible.

References