Is having systemd a requirement for limiting container cpu/memory?

Hi, I am trying Alpine Linux with Docker (rootless). Alpine comes with OpenRC and not systemd by default.

I get conflicting information, maybe because some of it is out of date. Essentially, current setup works, I have:

  • Docker in rootless mode running with standard user
  • Docker compose is also running OK, with containers being in healthy state for days now, it is very stable

The only problem is I have no way to limit the containers CPU and memory use. I just want to confirm if systemd is a strict requirement. From the warning message below, it appears that Docker is not detecting cgroups.

Attaching few bits from my device:

~ cat /etc/rc.conf | grep unified
# "hybrid" mounts cgroups version 2 on /sys/fs/cgroup/unified and
# "unified" mounts cgroups version 2 on /sys/fs/cgroup
rc_cgroup_mode="unified"


~ mount | grep cgroup
none on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)


~ docker info | grep Cgroup
WARNING: Running in rootless-mode without cgroups. Systemd is required to enable cgroups in rootless-mode.
 Cgroup Driver: none
 Cgroup Version: 2

~ docker stats
ID             NAME              CPU %     MEM USAGE / LIMIT   MEM %     NET I/O           BLOCK I/O    PIDS
8ac903c57668   wikijs       2.69%     0B / 0B             0.00%     3.79MB / 2.52MB   715MB / 0B   310

Docker supports exec options to change the cgroup driver which can be systemd or cgroupfs

https://docs.docker.com/reference/cli/dockerd/#configure-cgroup-driver

So systemd is not strictly required for cgroups in Docker, but if the error message says

it is probably true. You can also see the same statement in the documentation in the “Known limitations” section:

https://docs.docker.com/engine/security/rootless/#known-limitations

  • Cgroup is supported only when running with cgroup v2 and systemd. See Limiting resources.

This information provide you full details to solve critical problems that you face.