How to Configure Openfiles Limit for Docker Containers

The Ask

From the docker host (CentOS 7) is possible to see that the open files limit is set to 1024.

But the docker container has this limit set to 1048576

Is it possible to change this value for the docker containers?

The Answer

The open files limit is set by default to 1048576. This limit is not related to the host’s limit. There are 2 possible way how to change this limit:

global change (affects all containers)

1. In this case please modify the following lines in the /usr/lib/systemd/system/docker.service

2. Reload daemon config and restart the docker service.

Change specific container limit

In this case please run the container with the following option:

122880 is the hard and soft open files limit for the container “centos”.