Skip to content

[Docker] LXC resource limits ignored by Docker running inside jt #16756

Description

@frontend-report

Script: Docker

Reported by: @andrebrait

Guidelines

  • Read and understood guidelines: yes
  • Verbose mode used: yes

Issue occurs during: Initial Creation / Installation

Environment

  • Linux distribution: Debian
  • Proxmox version: 9.1
  • Default settings: No
  • Advanced settings: Yes
  • Exact command: var_os='debian' bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/docker.sh)"

Description

The script sets up an LXC container in a naive way so the Docker daemon running inside it does not respect and is not aware of the resource limits you set for the LXC.

Steps to reproduce

  1. Install Docker with this script. Choose a Memory limits below your maximum.
  2. Open a shell inside the LXC
  3. Run the following commands to see the Docker runtime cannot see the memory limits:
echo "CT sees:        $(head -1 /proc/meminfo)"
echo "container sees: $(docker run --rm alpine head -1 /proc/meminfo)"
echo "cgroup limit:   $(docker run --rm alpine cat /sys/fs/cgroup/memory.max)"

Error output

The output would be (64GB total system memory, 8GB set to the LXC, the "fixed" line is what I will propose as a solution).

broken:  MemTotal: 65648168 kB   memory.max: max
fixed:   MemTotal:  8388608 kB   memory.max: 8589934592

Additional context

Two commands that would have told you nothing — worth naming, because they're the obvious ones to reach for:

  • docker info reported MemTotal=8589934592 NCPU=6the entire time it was broken. The daemon runs as a plain CT process, so it reads thelxcfs /proc/meminfo` and looks perfectly healthy while every container it starts sees 62 GiB.
  • docker run --rm alpine free -m prints the host figure even after the fix is correctly applied. busybox free uses sysinfo(2), which lxcfs cannot intercept. Same for getconf _PHYS_PAGES and Node's os.totalmem().

Solution

We can use lxcfs to give containers running in Docker the proper visibility they need for their own resource consumption.

Some sources:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions