Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support container CPU & memory limits #30

Open
jimsynz opened this issue Mar 4, 2019 · 1 comment
Open

Support container CPU & memory limits #30

jimsynz opened this issue Mar 4, 2019 · 1 comment

Comments

@jimsynz
Copy link

jimsynz commented Mar 4, 2019

When running within a Docker container it is possible to get information about the CPU and memory limits from /sys/fs/cgroup.

For example /proc/meminfo shows the memory information of the host machine, however /sys/fs/cgroup/memory/memory.limit_in_bytes identifies exactly how much memory this container is allowed to allocate before being killed by the container runtime.

Correspondingly /proc/cpuinfo shows information about all host CPUs, and not the number of cores that the container is limited to.

Examples:

$ docker run --rm -it -m 128m --cpuset-cpus="0-0" alpine:latest cat /proc/meminfo | grep MemTotal
MemTotal:        8165020 kB
$ docker run --rm -it -m 128m --cpuset-cpus="0-0" alpine:latest cat /sys/fs/cgroup/memory/memory.limit_in_bytes
134217728
$ docker run --rm -it -m 128m --cpuset-cpus="0-0" alpine:latest cat /proc/cpuinfo | grep processor
processor	: 0
processor	: 1
$ docker run --rm -it -m 128m --cpuset-cpus="0-0" alpine:latest cat /sys/fs/cgroup/cpuset/cpuset.cpus
0
@rbtcollins
Copy link

Interesting overlap here with my effective_limits crate: I would happily consume container info from sysinfo if it has it, or some container specific abstraction as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants