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:

  • Running and configuring mqtt broker with docker composer
  • Unsure how I resolved a Docker networking issue to pkg repos
  • How can I open up webcam and process images with docker and OpenCV?
  • Docker WordPress Nginx Folder Structure?
  • Unable to set Docker container hostname via Marathon Json file
  • Docker killed by system when build
  • $ 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.

  • ffmpeg image and flask app in two different containers in Docker compose. How do I use ffmpeg in flask app?
  • Should I include my webapp source in my docker image, or mount it when i run a container?
  • Glassfish Docker EAR deploy failing authentication
  • Unable to mount MySQL data volume to Kubernetes Minikube pod
  • Why env variables are not created automatically?
  • How to connect docker's container with pipeline
  • 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.