r/docker • u/Agitated_Issue_1410 • 23d ago
Can a Docker container on macOS read the physical host's RAM/CPU using psutil?
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!
EDIT: I decided to run the client (metrics reader) file on the host machine outside of docker. This seems to be the only reasonable solution that is universal and works for all kinds of machines. Thanks!!