Below are several practical ways to look at “real” RAM consumption of a container, rather than the lump-sum amount macOS (or Windows) shows for the Podman/Docker/OrbStack VM process itself.
The 5-second answer
================================================================================
• Linux host → docker stats, podman stats, or crictl stats already read the cgroup counters and are usually “good enough”.
• macOS / Windows → those same commands still work; they ask the Linux daemon that runs inside the hidden VM, so the numbers you see are the container’s actual cgroup usage, not the whole VM.
If you need to double-check or script it more precisely, continue reading.
================================================================================
2. Understanding what you’re looking at
Host OS (macOS) -> sees one big qemu/hyperkit/AppleHV process
Linux VM (Docker / Lima) -> sees normal Linux pids, each in a cgroup
Cgroup -> tracks memory.current, memory.swap.current, etc.
Container runtime -> reads those cgroup files and shows you “stats”
Therefore, the only trustworthy source is the cgroup files inside the VM.
================================================================================
3. One-liner: read the cgroup file yourself
(works on any modern cgroup-v2 system; adjust paths for v1)
bash
# 1. Get the container’s main PID inside the Linux VM
CID=mycontainer # name or short id
PID=$(docker inspect -f '{{.State.Pid}}' $CID)
# 2. Find the cgroup path that PID belongs to
CG=$(grep memory /proc/$PID/cgroup | cut -d: -f3)
# 3. Read the memory counters
cat /sys/fs/cgroup$CG/memory.current # bytes currently used
cat /sys/fs/cgroup$CG/memory.max # limit (0 = unlimited)
cat /sys/fs/cgroup$CG/memory.stat # detailed breakdown
Under cgroup-v1 the files are called memory.usage_in_bytes, memory.limit_in_bytes, etc.
================================================================================
4. Friendly commands that already do the heavy lifting
Command What it shows Works with
docker stats RSS + cache + swap in real-time Docker, OrbStack
podman stats same Podman (Linux & macOS w/ podman-machine)
kubectl top pod … aggregated cgroup data via metrics-server Kubernetes
crictl stats for CRI runtimes (containerd, cri-o) Any CRI install
cadvisor / Prometheus full historical metrics Any container host
Tip: Add --no-stream to get a single snapshot instead of a live watch.
================================================================================
5. Inspect from inside the container
Inside the container you can run ordinary tools, but remember:
• top, htop, free respect the cgroup limit and only see memory
the container is allowed to consume, not what the whole host has.
================================================================================
6. macOS / Windows specifics
Docker Desktop:
• The app UI shows the VM’s overall footprint; use docker stats for per-container.
• The Linux VM is hidden; if you really want in, run
docker run --privileged --pid=host --rm -it alpine nsenter -t 1 -m -u -n -i sh.
Podman-machine:
• podman machine ssh → you land in the Fedora CoreOS VM. Then podman stats.
OrbStack:
• CLI: orbstack shell (or simply orbstack exec <cmd>).
• Once inside the VM, same cgroup files apply.
WSL2:
• Each Docker / Nerdctl container is in a cgroup below /sys/fs/cgroup/docker/….
================================================================================
7. Quick cheat-sheet for scripts
================================================================================
8. Why numbers sometimes look “too high”
• File cache is counted; if the container reads a lot from disk, usage spikes.
• Shared pages (glibc, alpine base layers) are only counted once at the cgroup level, so different containers don’t double-count, but inside each container’s top they appear as if fully private.
• On macOS the host additionally keeps copies of those pages in the VM process, so Activity Monitor shows more than the Linux numbers. That’s normal.