You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
setup_docker: make LXC resource limits visible to nested containers
Inside an LXC container, Docker gives every container it starts a fresh
procfs in its own mount namespace. The lxcfs bind mounts that LXC placed
on /proc/meminfo and friends live in the CT's namespace and never reach
it, so each Docker container reads the physical host's totals instead of
the CT's limits:
CT sees: MemTotal: 8388608 kB
container sees: MemTotal: 65648168 kB
Enforcement was never affected, since the CT cgroup still caps every
descendant. Visibility was, and anything that self-sizes from those
numbers - JVM heap ergonomics, Node, Go, OpenMP thread pools - sizes
against the wrong value and gets OOM-killed instead of throttling.
Register a small runc wrapper as Docker's default runtime. On each
container create it re-binds the lxcfs-backed files into the container
and, when the container sets no limit of its own, applies the CT's
memory limit to the container cgroup. Both halves are needed because
runtimes read the limit two different ways: file readers use /proc,
while musl and Node's uv_get_constrained_memory() consult the cgroup.
CPU needs no handling - cpuset is inherited down the cgroup tree, so
nested containers already observe the CT's core count. The one exception
is /sys/devices/system/cpu/online, which glibc's sysconf(_SC_NPROCESSORS_ONLN)
reads, so it is bound alongside the /proc files.
The helper is a no-op outside an LXC container and wherever lxcfs is not
mounted, so the five non-Docker installers that call setup_docker are
unaffected. It fails open: no runc, no jq, or malformed JSON all fall
through to the real runc unmodified, degrading to current behaviour
rather than breaking the daemon. Opt out with DOCKER_LXCFS_VISIBILITY=false.
Regenerate lib/API.txt for the new function.
0 commit comments