5.17 Setting ulimit Values on Containers

The --ulimit option to docker run allows you to specify ulimit values for a container, for example:

$ docker run -i -t --rm myapp:2.0 --ulimit nofile=128:256 --ulimit nproc=32:64

This example sets a soft limit of 128 open files and 32 child processes and a hard limit of 256 open files and 64 child processes on the container.

You can set default ulimit values for all containers by specifying default-ulimits options in a /etc/docker/daemon.json configuration file, for example:

"default-ulimits": {
  "nofile": {
      "Name": "nofile",
      "Hard": 128,
      "Soft": 256
    },
    "nproc" : {
      "Name": "nproc",
      "Hard": 32,
      "Soft": 64
    }
},
Note

After adding or modifying the configuration file while the docker service is running, run the command systemctl daemon-reload to tell systemd to reload the configuration for the service.

Any ulimit values that you specify for a container override the default values that you set for the daemon.