Enabling cgroup v2 on RHEL 8 for Docker/Podman
Issue
Fix container runtime issues when running images with cgroup v2 on a cgroup v1 host.
How to enable cgroup v2 on RHEL 8?
Is Docker/Podman compatible with cgroup v2 on RHEL 8?
Resolution
By default, RHEL 8 runs on cgroup v1. However, you can switch to using cgroup v2 by adding the systemd.unified_cgroup_hierarchy=1
parameter to the kernel command line and rebooting.
Using the grubby Tool
To modify the kernel command line, use the grubby
tool:
# grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=1"
After applying the change, reboot your system:
# reboot
Verify cgroup v2 Activation
Once the system has rebooted, check whether cgroup v2 is enabled by running:
# mount -l | grep cgroup
Expected output:
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
If you see cgroup2
mounted at /sys/fs/cgroup
, cgroup v2 is successfully enabled.
Configuring Docker/Podman to Use cgroup v2
Docker
To ensure Docker runs with cgroup v2, create or modify the Docker daemon configuration file:
# mkdir -p /etc/docker
# echo '{"exec-opts": ["native.cgroupdriver=systemd"]}' > /etc/docker/daemon.json
# systemctl restart docker
Podman
Podman natively supports cgroup v2. Ensure that your system is using the systemd
driver:
# echo 'cgroup_manager = "systemd"' >> /etc/containers/containers.conf
Restart any running containers or services using Podman to apply the changes.
Additional Notes
Ensure that your container runtime (Docker/Podman) fully supports cgroup v2 before making the switch.
Some workloads may require additional configuration adjustments.
Use
docker info
orpodman info
to verify that cgroup v2 is being used.
By following these steps, you can successfully enable and configure cgroup v2 on RHEL 8 for Docker and Podman.