Docker 容器没有从主机继承 ulimit
Docker container does not inherit ulimit from host
我已阅读 here docker
容器从主机继承 ulimit
属性。我的容器似乎没有发生这种情况。特别是,我需要 max locked memory
属性 从主机继承。有人知道怎么解决吗?
ubuntu@host:~$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 31404
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 50000
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 50000
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
ubuntu@host:~$ docker exec -it container /bin/bash
root@container:/# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 31404
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 524288
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 524288
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
如果要为容器设置自定义 ulimits,可以使用 --ulimit
选项。例如;
docker run -it --rm --ulimit memlock=32768:32768 ubuntu sh -c "ulimit -a"
显示:
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) unlimited
stack(kbytes) 8192
coredump(blocks) 0
memory(kbytes) unlimited
locked memory(kbytes) 32
process 7873
nofiles 1024
vmemory(kbytes) unlimited
locks unlimited
您可以在文档中找到更多信息; https://docs.docker.com/engine/reference/commandline/run/
有关限制容器资源的其他方法,另请参阅本节;
https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources
我已阅读 here docker
容器从主机继承 ulimit
属性。我的容器似乎没有发生这种情况。特别是,我需要 max locked memory
属性 从主机继承。有人知道怎么解决吗?
ubuntu@host:~$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 31404
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 50000
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 50000
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
ubuntu@host:~$ docker exec -it container /bin/bash
root@container:/# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 31404
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 524288
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 524288
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
如果要为容器设置自定义 ulimits,可以使用 --ulimit
选项。例如;
docker run -it --rm --ulimit memlock=32768:32768 ubuntu sh -c "ulimit -a"
显示:
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) unlimited
stack(kbytes) 8192
coredump(blocks) 0
memory(kbytes) unlimited
locked memory(kbytes) 32
process 7873
nofiles 1024
vmemory(kbytes) unlimited
locks unlimited
您可以在文档中找到更多信息; https://docs.docker.com/engine/reference/commandline/run/
有关限制容器资源的其他方法,另请参阅本节; https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources