Reputation: 3739
I'm running the following docker command:
docker run node -e "setTimeout(() => console.log('hello world'), 10000)"
Now, docker stats
gives me:
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
54b80bd39f0a magical_babbage 0.00% 6.688MiB / 15.41GiB 0.04% 3.33kB / 0B 0B / 0B 7
Telling me that it's only using 6.88MiB.
Does docker not include the memory needed to run the host OS?
Upvotes: 3
Views: 3218
Reputation: 615
Docker containers are run by a single operating system kernel which means that it does not run the OS as it would in a VM or on the host. Where an OS installed on a VM or host is booted as a "live" OS, Docker waits till it needs to use a specific process, this is achieved because Docker is loaded as a daemon process (dockerd) on the host machine.
The Alpine Linux image which is a widely used distro for Docker containers is only around 2.5MB in size. So you can understand that the memory usage for a Docker container using Alpine is very low.
The output you see with docker stats
is the complete memory used by your container.
See Dockers metrics documentation for extensive information.
https://docs.docker.com/config/containers/runmetrics/
Upvotes: 6