brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: docker run --ulimit nofile raises the open files limit of one container

Docker
~/tips/tip-docker-run-ulimit-nofile

docker run --ulimit nofile=1024:1024 --rm debian sh -c "ulimit -n"

Sets the soft and hard limit for open files of a single container.

The error “too many open files” in a container log is a good reason to learn this flag. You can raise the limit for that one container and leave the rest of the host alone.

The format is --ulimit <type>=<soft limit>[:<hard limit>], and nofile is the maximum number of open file descriptors. If you leave out the hard limit, the soft one is used for both. The reference shows how to check what a container sees:

docker run --ulimit nofile=1024:1024 --rm debian sh -c "ulimit -n"

That prints 1024. For an app that keeps many sockets or files open, give it more room:

docker run -d --name search --ulimit nofile=65536:65536 example/search:1.0

Docker applies the limit when it starts the container, so you have to recreate the container to change it. Some apps also have their own setting for the maximum number of connections, and that may need a change too. Raising the number is usually harmless, and the app’s documentation is the best place to find a sensible value.

Further reading: docker run reference: ulimit

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link