1.3.1.3 Resource Overhead Contrast
A focused guide to Resource Overhead Contrast, connecting core concepts with practical Docker and container operations.
Resource overhead contrast quantifies the difference in CPU, memory, and disk cost between running a workload in a Docker container versus running the same workload in a virtual machine, isolating exactly where that overhead comes from.
Where Virtual Machine Overhead Comes From
A virtual machine's overhead starts before the application even runs: a guest kernel must be loaded, system services inside the guest OS must start, and a fixed allocation of memory is typically reserved for the VM regardless of how much the application actually uses at any given moment.
free -h
Run inside a VM, a meaningful portion of reported memory usage often belongs to the guest operating system itself rather than to the application it is hosting.
Where Container Overhead Comes From
A container's overhead is comparatively minimal: there is no guest kernel to load, and the container's own filesystem is typically just the application and its declared dependencies layered on a small base image.
docker stats --no-stream
This command reports the actual resource usage of running containers, and for a lightweight application, the reported memory and CPU usage is often close to what the bare application process itself would use outside any container.
Comparing Image Size to VM Disk Footprint
A minimal container image can be a few megabytes, while a virtual machine image, including a full guest operating system, is typically measured in hundreds of megabytes to several gigabytes.
docker images --format '{{.Repository}}:{{.Tag}} {{.Size}}'
Density Implications
Because each container avoids the fixed overhead a VM requires, a single host can typically run many more containers than it could run equivalent virtual machines, which directly affects infrastructure cost at scale — fewer physical or virtual hosts are needed to run the same number of isolated workloads.
docker run --memory=64m --cpus=0.25 myapp:lightweight
A constraint this tight is realistic for a small container but would be impractical for a virtual machine, which needs enough resources to run an entire operating system underneath the application.
When Overhead Differences Matter Most
Resource overhead differences matter most at scale — running ten containers versus ten virtual machines makes a modest difference, but running thousands of instances of a workload makes the overhead difference a significant factor in overall infrastructure cost and achievable density per host.