Cgroup V2 the saga continues

In the recent past I was able to have old systemd (because testing ansible roles using molecule+docker is nice) versions running (dreadful amazonlinux:2) fine by running the container with:
–privileged --cgroupns=host -v /sys/fs/cgroup:/sys/fs/cgroup:rw

But I also had to add cgroup_no_v1=all to linuxkit kernel parameters in:

Which is not anymore in the latest version of Docker desktop (24.0.7)… So could any helpful guru show me the enlightened path to send this parameter to the latest linuxkit docker image?

ps. I really wanted to create my own linuxkit image to avoid going through the whole internet every time docker devs changes it but it seems really really hard to tame the underlying linux image docker desktop uses…

Testing Dockerfile

FROM amazonlinux:2

VOLUME [ "/tmp", "/run", "/run/lock" ]

# Mostly tested with SuSe and Amazon Linux
RUN yum -y update && yum install -y rsyslog logrotate tar unzip gzip dbus systemd systemd-sysv python3 python3-setuptools python3-pip bash iproute net-tools sudo vim

WORKDIR /lib/systemd/system/
# hadolint ignore=SC2086

RUN cd /lib/systemd/system/ ; \
    for i in *; do [ $i = systemd-tmpfiles-setup.service ] || rm -f $i ; done ; \
    rm -f /lib/systemd/system/* ; \
    rm -f /etc/systemd/system/*.wants/* ; \
    rm -f /lib/systemd/system/* ; \
    rm -f /lib/systemd/system/*udev* ; \
    rm -f /lib/systemd/system/*initctl* ; \
    rm -f /lib/systemd/system/* ; \
    rm -f /lib/systemd/system/*

RUN sed -i 's/OOMScoreAdjust=-900//' /lib/systemd/system/dbus.service


ENTRYPOINT ["/lib/systemd/systemd"]

That’s the version of Docker, not the Desktop. The Destkop version can change even if the Docker version stays the same, but the Docker version can’t change without the Docker Desktop version.

I didn’t know about the cmdline file and I’m surprised that was even there. What wouldn’t surprised me if Docker Inc was trying to make any customization even harder for easier support. I would still tell you if I knew a solution, but I don’t.

What I could recomend is asking for Systemd support in Docker Desktop on GitHub: Issues · docker/roadmap · GitHub

Obviously you need a solution sooner, so the second I would do is using a custom virtual machine for the systemd tests. You could also try Podman Desktop. Podman claims to support Systemd, so I would assume they support it in Podman Desktop as well, but I don’t know for sure, because I don’t use it. I just tried once…

You can also try something like Jeff Geerling does in his images. I’m pretty sure you know his name if you work with Ansible. He doesn’t use a real systemd, but a fake one. I tried that and I think I had some problem with it, but I don’t remember what. Here is an issue related to macOS:

Here is a repo for Amazon Linux 2023:

and one for Amazon Linux 2

Thanks for the great answer, rimelek. :slight_smile:

Yesterday evening I’ve ended up just using a local directory (e.g. /tmp/systemd) with cgroupns set to host:

docker run --rm -it --privileged --cgroupns host -v /tmp/systemd:/sys/fs/cgroup:rw al2

al2 being the container built using Dockerfile of the post. Somehow linux is able to do it’s cgroup thing:

cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)

And the old version of systemd is working.

p.s.: I’ve taken the version from this page: Docker Desktop release notes | Docker Docs
I thought the engine (24.0.7) was the Docker version

1 Like

Yes, but not the Docker Desktop version which you wrote in your post. The page is Docker Desktop release notes, so the Docker Desktop release versions are the biggest numbers in size you can find there :slight_smile:

But thank you for sharing the solution. I wasn’t sure if current desktop versions required the cmdline parameter, because it was so long when I tried systemd in a container. When I did, I mounted folders, but I never even heard about the parameter you mentioned. So I learned something too :slight_smile: