Docker Community Forums

Share and learn in the Docker community.

Resources usage by container

Hello,

How Docker manage resources especially RAM and CPU usage.
For example I run two containers:

1# Postgres
2# Application

Total memory of host is 8GB.

  • How then it will use memory?
  • Is this possible to tweak limit resources for certain container?
    Let’s say I want give for container no1. 6GB of RAM and rest for container no.2

I would be surprised if somone actualy runs container in production without setting ressource constraints (reservations/limits) for CPU and RAM.

Check the documentation of docker cli or the compose file reference on how to apply the settings.

Running docker stats on all running containers against a Linux daemon.

$ docker stats

CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
b95a83497c91 awesome_brattain 0.28% 5.629MiB / 1.952GiB 0.28% 916B / 0B 147kB / 0B 9
67b2525d8ad1 foobar 0.00% 1.727MiB / 1.952GiB 0.09% 2.48kB / 0B 4.11MB / 0B 2
e5c383697914 test-1951.1.kay7x1lh1twk9c0oig50sd5tr 0.00% 196KiB / 1.952GiB 0.01% 71.2kB / 0B 770kB / 0B 1
4bda148efbc0 random.1.vnc8on831idyr42slu578u3cr 0.00% 1.672MiB / 1.952GiB 0.08% 110kB / 0B 578kB / 0B 2
Admin
Apps4Rent