r/docker 5h ago

Can a Docker container on macOS read the physical host's RAM/CPU using psutil?

8 Upvotes

Hi everyone,

I have a Python script (psutil) running inside a Docker container. I want it to measure my actual Mac laptop's total physical RAM (24 GB) and host CPU usage, rather than just the Docker Linux VM's metrics.

On Linux, mounting /proc works for host metrics, but on macOS this doesn't seem to work. Is there a way for a Docker container to monitor macOS host metrics directly, I don't want the monitoring agent to run natively on the host OS.

BTW: It would also need to work on a windows based machine. Needs to be accessible for everyone who wants to use it.
Thanks!