I have a Python monitoring script using psutil inside a Docker container. On a Mac laptop with 24 GB of physical RAM, I want it to report the actual host's total memory and CPU usage—not just the resources visible inside Docker's Linux virtual machine. Mounting /proc works for host metrics on native Linux, but Docker Desktop on macOS and Windows runs containers inside a VM, so that approach doesn't seem to apply. Is there a portable way to let the container read host-level metrics directly without installing the monitoring agent natively on each host operating system?
4 Answers
The practical cross-platform solution is to run a small metrics exporter on the host and have the container query it over the local network. For example, a Prometheus-compatible exporter can expose CPU and memory data from macOS or Windows, while your container reads the HTTP endpoint. It does mean running a host-side component, because the container cannot bypass the virtualization boundary by itself.
Increasing or changing Docker Desktop’s CPU and memory settings only changes the VM limits. It does not make the physical host’s metrics visible inside the container. Windows containers are a separate case, but a Linux-based container still cannot assume it can inspect the Windows host kernel directly.
You could theoretically expose host information through a mounted filesystem or another integration, but there is no macOS equivalent of Linux’s /proc that Docker can simply bind-mount. Any host filesystem data would use an OS-specific format and require custom parsing, so it would not provide a clean portable psutil solution.
Not directly. On macOS and Windows, Docker Desktop normally runs the Linux container inside a Linux VM. psutil and /proc can only see the kernel and resource limits of that VM, so the container will report the VM’s memory and CPU rather than the physical computer’s values. Native Linux is different because containers share the host Linux kernel.

Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures