desktop-linux
desktop-linux copied to clipboard
how to get container memory limit in docker container?
- [x ] I have tried with the latest version of Docker Desktop
- [x ] I have tried disabling enabled experimental features
- [ ] I have uploaded Diagnostics
- Diagnostics ID:
Expected behavior
Actual behavior
Information
- Linux distro:
- Distro version:
- Docker Desktop Version:
Steps to reproduce the behavior
when I run docker with -m 20g parameter, docker container is 20g when I run docker without -m parameter, docker container is host machine's memory. docker stats command can get right memory size.
but when I need deploy a application in docker container, this application need docker container memory size, i read /sys/fs/cgroup/memory/memory.limit_in_bytes, it is 9223372036854771712. If I read /proc/meminfo, it is host machine' memory size. how can I read a container memory size conrrectly?
@thaJeztah is there a way to find the memory limit from inside the container?
I also want to know how to get it
From inside the container do: cat /sys/fs/cgroup/memory.max (note this is for Alpine).
There hasn't been any activity on this issue for a long time.
If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment.
If not, this issue will be closed in 30 days.
Prevent issues from auto-closing with a /lifecycle frozen comment.
/lifecycle stale