2016-03-30 71 views
1

我已閱讀heredocker容器從主機繼承ulimit屬性。這似乎不會發生我的容器。特別是,我需要max locked memory屬性從主機繼承。有誰知道如何修理它?碼頭集裝箱不會從主機繼承ulimit

[email protected]:~$ 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 
[email protected]:~$ docker exec -it container /bin/bash 
[email protected]:/# 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 
+0

您運行的是什麼版本的docker服務器和客戶端?什麼是主機操作系統? –

+0

'客戶: 版本:1.10.2 API版本:1.22 轉到版本:go1.5.3 git的承諾:c3959b1 內置:星期一2月22日21時37分01秒2016 OS /拱門:LINUX/AMD64 服務器: 版本:1.10.2 API版本:1.22 轉到版本:go1.5.3 git的承諾:c3959b1 內置:星期一2月22日21時37分01秒2016 OS /拱門:LINUX/AMD64 ' – lingxiao

+0

主機操作系統是Ubuntu 14.04.3 LTS(GNU/Linux 3.13.0-66-generic x86_64) – lingxiao

回答

2

如果要爲容器設置自定義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