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
- Install Docker with this script. Choose a Memory limits below your maximum.
- Open a shell inside the LXC
- 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:
Script: Docker
Reported by: @andrebrait
Guidelines
Issue occurs during: Initial Creation / Installation
Environment
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
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).
Additional context
Two commands that would have told you nothing — worth naming, because they're the obvious ones to reach for:
docker inforeported 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 -mprints the host figure even after the fix is correctly applied. busyboxfreeusessysinfo(2), whichlxcfscannot intercept. Same forgetconf _PHYS_PAGESand Node'sos.totalmem().Solution
We can use lxcfs to give containers running in Docker the proper visibility they need for their own resource consumption.
Some sources: