logo

Configure Docker ulimits

Issues

Solution

Configure ulimits of one container in docker-compose.yml:

services:
  <container>:
    ulimits:
      nofile:
        soft: 262144
        hard: 262144

Or, make it default for all new containers by modifying /etc/docker/daemon.json:

{
  "experimental": true,
  "default-ulimits": {
    "nofile": {
      "Name": "nofile",
      "Hard": 262144,
      "Soft": 262144
    }
  }
}

then, run:

$ sudo systemctl restart --now docker
$ docker run --rm ubuntu:20.04 bash -c 'ulimit -Hn && ulimit -Sn'
262144
262144