Cannot reduce ulimits inside docker container
I have a script that writes a 10k file, and reports successs:
$ perl examples/largefile.pl Begin End
I can prevent it from running to completion, as expected, with
$ ( ulimit -f 5 ; perl examples/largefile.pl ) Begin
Unfortunately, inside a cocker container, the
ulimit -f command doesn’t seem to haven an effect:
$ 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
but note how
ulimit believes it had an effect:
user@08aba80ebaff:/...$ ( ulimit -f; ulimit -f 5; ulimit -f) unlimited 5
docker run does not help.
This is related to my earlier question, but there I wonder about inheriting limits from the caller to
docker run, whereas here I wonder about setting limits inside the container.
One Solution collect form web for “Cannot reduce ulimits inside docker container”
It seems that this was recently implemented in docker: https://github.com/docker/docker/issues/4717