geerlingguy / docker-ubuntu2204-ansible

Ubuntu 22.04 LTS (Jammy Jellyfish) Docker container for Ansible playbook and role testing.
https://hub.docker.com/r/geerlingguy/docker-ubuntu2204-ansible
MIT License
69 stars 17 forks source link

This image does not run on Ubuntu 22.04 #4

Open artinesrailian opened 2 years ago

artinesrailian commented 2 years ago

Hi Jeff,

When trying to run "docker run geerlingguy/docker-ubuntu2204-ansible" the container ends up in Exited (255) status code on Ubuntu 22.04 machine. It works pretty well on Ubuntu 20.04, but there is an issue with Ubuntu 22.04 that it does not work. I don't know what might be causing the issue, if you have any idea how I can check it, please let me know in order to provide more detailed information.

geerlingguy commented 2 years ago

Are there any logs you can find, and what command are you using to run the container?

artinesrailian commented 2 years ago

I am using the command provided on the docker hub docker run --detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro geerlingguy/docker-ubuntu2204-ansible:latest

This is the only log I could find from the output of journalctl -xe journalctl.log

P.S. everything started, when I tried to use this image on my newly created VM (Ubuntu 22.04) to run molecule tests, then tried to dig deeper by running the container manually to figure out why the molecule test is unable to create the environment.

artinesrailian commented 2 years ago

There is also one other off-topic issue I just faced on an ansible-controller hosted on Ubuntu 22.04, that when using other images like CentOS 7 and CentOS 8 (both tested), the docker container systemd unit which is mocked does not work (they are working great on Ubuntu 20.04). Apologies for posting in the wrong place, but I didn't know where to post it, as it seems a global issue, related to all images not being able to mock systemd unit within the docker container which is hosted on Ubuntu 22.04.

csmart commented 2 years ago

Is the problem that the latest Ubuntu finally switched to use cgroupsv2 and the container is not supported on docker unless the host is running cgroupsv1?

ossie-git commented 2 years ago

I ran into this issue as well and I confirmed that it is related to cgroupsv2. There are some workarounds mentioned here that work and can be used as temporary workarounds.

For example, I tested the following two workarounds and they worked.

Workaround 1

Make the following changes to the docker command:

so your command would look like this:

docker run --cgroupns=host --detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:rw geerlingguy/docker-ubuntu2204-ansible:latest

Workaround 2

Run a hybrid cgroups setup using:

# echo 'GRUB_CMDLINE_LINUX=systemd.unified_cgroup_hierarchy=false' > /etc/default/grub.d/cgroup.cfg
# update-grub

and then reboot and you can then run these containers normally:

docker run --detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro geerlingguy/docker-ubuntu2204-ansible:latest
mathieufrh commented 7 months ago

I ran into this issue as well and I confirmed that it is related to cgroupsv2. There are some workarounds mentioned here that work and can be used as temporary workarounds.

For example, I tested the following two workarounds and they worked.

Workaround 1

Make the following changes to the docker command:

  • add --cgroupns=host
  • mount /sys/fs/cgroup rw

so your command would look like this:

docker run --cgroupns=host --detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:rw geerlingguy/docker-ubuntu2204-ansible:latest

Workaround 2

Run a hybrid cgroups setup using:

# echo 'GRUB_CMDLINE_LINUX=systemd.unified_cgroup_hierarchy=false' > /etc/default/grub.d/cgroup.cfg
# update-grub

and then reboot and you can then run these containers normally:

docker run --detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro geerlingguy/docker-ubuntu2204-ansible:latest

Workaround 1 wasn't enough to make it work. Workaround 2 is ok though. Thank you very much.