3

Can ulimit on containers within docker daemon process be higher than the limit of the daemon process itself?

Docker documentation does not mention anything about this:

From : https://docs.docker.com/engine/reference/commandline/dockerd/#default-ulimit-settings

--default-ulimit allows you to set the default ulimit options to use for all containers. It takes the same options as --ulimit for docker run. If these defaults are not set, ulimit settings will be inherited, if not set on docker run, from the Docker daemon. Any --ulimit options passed to docker run will overwrite these defaults.

djangofan
  • 4,182
  • 10
  • 46
  • 59
  • Im looking for the same answer. In my case its the ECS Optimised AMI that im using. It has a `unlimit -n` set to `1024`. I can set a high number for the containers. But im not sure if the container will ever be able to use the higher limit – Saad Masood Jul 23 '18 at 14:17

1 Answers1

3

I've checked with Amazon Linux and it looks like it can.

Let's check it via adjusting ulimit for max number of opened files:

  1. Max number of opened file limits of the docker daemon:
cat /proc/$(ps -A | grep dockerd | awk '{print $1}')/limits | grep "files"

If the docker daemon is running, the output is:

Max open files            65536                65536                files
  1. Now run a docker container with adjusted ulimits (let it be python, but be sure another python does not run on your machine):
# run container in daemon mode
docker run -d -it --rm --ulimit nofile=99999:99999 python python;
# show max files for the python process
cat /proc/$(ps -A | grep python | awk '{print $1}')/limits | grep "files"

The output:

Max open files            99999                99999                files