【问题标题】:Cannot reduce ulimits inside docker container无法减少 docker 容器内的 ulimit
【发布时间】:2014-09-11 13:58:37
【问题描述】:

我想在 docker 容器中使用 ulimit -f减少限制。 (我强调这一点,因为围绕这个问题的许多问题和答案都涉及增加限制)。

我有一个写入 10k 文件并报告成功的脚本:

$ perl examples/largefile.pl
Begin
End

我可以使用ulimit -f 阻止它按预期运行到完成:

$ ( ulimit -f 5 ; perl examples/largefile.pl )
Begin

不幸的是,在可卡容器内,ulimit -f 命令似乎没有效果:

$ sudo docker run --rm -i -t -u 1001 -v $PWD:$PWD safe-docker bash
user@08aba80ebaff:/$ cd ...
user@08aba80ebaff:/...$ examples/largefile.pl
Begin
End
user@08aba80ebaff:/...$ ( ulimit -f 5 ; perl examples/largefile.pl )
Begin
End

但请注意ulimit 相信它是如何产生影响的:

user@08aba80ebaff:/...$ ( ulimit -f; ulimit -f 5; ulimit -f)
unlimited
5

--privileged 传递给docker run 没有帮助。

这与我的earlier question 有关,但我想知道继承从调用者到docker run 的限制,而在这里我想知道在容器内设置限制。

【问题讨论】:

    标签: docker ulimit


    【解决方案1】:

    好像最近在docker中实现了这个:https://github.com/docker/docker/issues/4717

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-24
      • 1970-01-01
      • 1970-01-01
      • 2018-02-13
      • 2019-03-25
      • 2017-11-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多