Skip to content

Fix Docker No Memory Limit Support on Raspberry Pi

If Docker reports No memory limit support, first check whether Linux exposes the cgroup memory controller on the Pi. The same check helps when K3s cannot find the memory cgroup or a systemd service accepts MemoryMax= but has no memory.max file.

Check whether the Pi has the memory controller

Run these on the Pi that hosts Docker or K3s.

1
2
3
4
5
6
# Check the cgroup filesystem and the controllers available at its root.
stat -fc %T /sys/fs/cgroup
cat /sys/fs/cgroup/cgroup.controllers

# Show cgroup switches from the running kernel's command line.
tr ' ' '\n' < /proc/cmdline | grep -E '^cgroup_(enable|disable)='

For a cgroup v2 installation, the filesystem type is cgroup2fs. Check for the word memory in the controller list. The final command prints matching boot switches if they are present. Linux cgroup v2 controller reference

What you see What to check next
The root list lacks memory and the kernel has cgroup_disable=memory Enable the controller through the Raspberry Pi OS kernel command line.
The root list has memory, but the workload's cgroup has no memory.max Check which managers control the workload's cgroup and whether the controller is enabled for that subtree. For rootless Docker, check controller delegation to its user service.
The root list lacks memory and the kernel has no matching boot switch Check the running kernel's memory cgroup support and the OS's cgroup configuration.

On a Pi 4B with Trixie and kernel 6.18.50+rpt-rpi-v8, the root listed cpuset cpu io pids and the running kernel had cgroup_disable=memory. A temporary user service reported MemoryMax=33554432, while its live cgroup had no memory.max. The installed kernel configuration reported CONFIG_MEMCG=y.

Enable the controller on Raspberry Pi OS

On Bookworm and Trixie, back up /boot/firmware/cmdline.txt, then open it with sudoedit /boot/firmware/cmdline.txt. Older Raspberry Pi OS releases use /boot/cmdline.txt. On the existing line, append a space and this setting:

cgroup_enable=memory

Keep the original boot parameters on that single line. The running command line can include firmware-supplied settings. On the tested Pi, the disable switch was in the running device tree's boot arguments even though it was absent from the saved file. The Raspberry Pi kernel's cgroup_enable= option can re-enable the named controller. Raspberry Pi kernel source · Raspberry Pi boot command line

Reboot when local recovery access is available. Rerun the checks and look for memory in cgroup.controllers. Use that list to verify the effective result even if the command line contains both switches.

Verify the limit on the workload

For Docker, check the engine's warnings with docker info using your normal access method. For a running container configured with a memory limit, use docker stats and compare the MEM USAGE / LIMIT column with the expected value. Replace my-container with its name.

docker info
docker stats --no-stream my-container

If Docker is rootless, its service also needs the memory controller in the delegated cgroup. Docker resource limits · Rootless Docker resource limits · Docker stats reference

For a running systemd service, compare the configured property with the cgroup file. Use systemctl --user in the first two commands for a user service.

1
2
3
4
5
# Replace my-app.service with the unit running the workload.
unit=my-app.service
systemctl show -p MemoryMax "$unit"
group=$(systemctl show -p ControlGroup --value "$unit")
test -n "$group" && cat "/sys/fs/cgroup$group/memory.max"

A number in memory.max is the limit in bytes. max means no limit at that cgroup level. An ancestor can still impose a lower ceiling. systemd resource controls · Service cgroup checks

Donate