Cannot reduce ulimits inside docker container

I want to use ulimit -f inside a docker container to reduce the limits. (I stress this as many questions and answers around this involve increasing limits).

I have a script that writes a 10k file, and reports successs:

  • Can't figure out how I have to build my Docker architecture
  • Docker cannot establish connection with postgresql in Travis CI
  • What would be pros and cons of using Docker Vs Vanilla LXC?
  • docker push not actually updating ECR
  • Docker env missing with fabric8
  • connection reset by peer when querying dockerized gunicorn
  • $ perl examples/largefile.pl
    Begin
    End
    

    I can prevent it from running to completion, as expected, with ulimit -f:

    $ ( 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
    

    Passing --privileged to 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.

  • Linking Multiple Docker Swarms
  • Persisting a dockerized WordPress (with LAMP stack)
  • Cannot hit docker container running locally
  • Dockerized Django On Ubuntu
  • Setting Docker container hostname on Elastic Beanstalk
  • Scaling: Docker containers vs Vms
  • 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

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.