dockerulimit

Docker build --ulimit flag has no effect


My docker builds are failing because of a file handle limit error. They crash out with

Error: EMFILE: too many open files

when I check ulimit -n on the container I see

-n: file descriptors 1024

So I pass the following flags to my build command

docker build --ulimit nofile=65536:65536 -t web .

but this does not change anything, my container still shows

-n: file descriptors 1024

No matter what I do I dont seem to be able to get that ulimit file descriptor limit to change.

What am I doing wrong here?


Solution

  • So, I discovered the cause. Posting the answer incase anyone else is having the same issue as I just wasted most of a day on this. I have been debugging a very long running build and have been using

    export DOCKER_BUILDKIT=1

    to enable some extended build information. Very useful timings etc, although it appears as though enabling DOCKER_BUILDKIT completely ignores ulimit flags passed to the docker build command.
    When I set

    export DOCKER_BUILDKIT=0

    it works. So long story short, avoid using buildkit with ulimit params