[SOLVED] Error: Failed to mount cgroup cgroup2 or systemd in Docker & Linux
When booting containers with Docker, Podman, or inside LXC containers on modern distributions (Ubuntu 24.04, Debian 12, Arch), users often hit Failed to mount cgroup: No such file or directory or unable to apply cgroup configuration. This friction stems from Linux transitioning from the legacy split cgroup v1 architecture to the unified cgroup v2 hierarchy.
Quick Diagnostics
When booting containers with Docker, Podman, or inside LXC containers on modern distributions (Ubuntu 24.04, Debian 12, Arch), users often hit Failed to mount cgroup: No such file or directory or unable to apply cgroup configuration. This friction stems from Linux transitioning from the legacy split cgroup v1 architecture to the unified cgroup v2 hierarchy.
Quick Solution (1 Minute):
- Check your active cgroup version:
stat -fc %T /sys/fs/cgroup/- If cgroup2fs breaks legacy container shims, set in /etc/default/grub:
systemd.unified_cgroup_hierarchy=0
Step-by-Step Solution
-
1
Step 1: Identify Host cgroup Tree Architecture
Run the filesystem type probe to inspect your running host kernel state:
BASHstat -fc %T /sys/fs/cgroup/- Output
cgroup2fsconfirms cgroup v2 is governing resource accounting. - Output
tmpfsindicates legacy cgroup v1.
- Output
-
2
Step 2: Fallback to Hybrid / Legacy cgroup Hierarchy via GRUB
If older orchestration tooling cannot parse cgroup v2, configure GRUB to restore compatibility:
BASHsudo nano /etc/default/grubAppend the kernel boot flag inside
GRUB_CMDLINE_LINUX_DEFAULT:PLAINTEXTGRUB_CMDLINE_LINUX_DEFAULT="quiet splash systemd.unified_cgroup_hierarchy=0"Update bootloader entries and reboot:
BASHsudo update-grub sudo reboot -
3
Step 3: Configure Native systemd cgroup Driver in Docker
For long-term reliability on modern kernels, configure Docker to natively utilize the
systemdcgroup driver in/etc/docker/daemon.json:JSON{ "exec-opts": ["native.cgroupdriver=systemd"] }Restart daemon to apply:
BASHsudo systemctl daemon-reload sudo systemctl restart docker
Frequently Asked Questions
What is the key advantage of cgroup v2 over v1 in production?
cgroup v2 prevents deadlocks caused by decoupled controller hierarchies and provides clean rootless container isolation alongside accurate memory OOM killing.
How do I resolve this issue in Proxmox LXC containers?
Add features: nesting=1 in your Proxmox container config (/etc/pve/lxc/ID.conf) to allow proper cgroup and systemd namespace delegation.
Prevention Advice
Recommended security practices:
- Keep container runtimes (containerd, runc, Docker CE) pinned to supported upstream packages.
- Avoid permanently pinning cgroup v1, as upstream Linux kernels and Kubernetes are phasing out v1 support.