Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker error: too many open files

Tags:

docker

I got that error message when creating container.

Error response from daemon: too many open files

But I couldn't find any information about that error. (I saw https://github.com/docker/libcontainer/issues/211, but that was not the same problem of it.) Is there anyone who knows about it?

Thanks.

like image 253
mayTree Avatar asked Apr 02 '15 00:04

mayTree


People also ask

How much RAM should I allocate to Docker?

Limit a container's access to memory The maximum amount of memory the container can use. If you set this option, the minimum allowed value is 6m (6 megabytes). That is, you must set the value to at least 6 megabytes. The amount of memory this container is allowed to swap to disk.

How do I fix permission denied Docker?

If running elevated Docker commands does not fix the permission denied error, verify that your Docker Engine is running. Similar to running a docker command without the sudo command, a stopped Docker Engine triggers the permission denied error. How do you fix the error? By restarting your Docker engine.

How do I force all Docker containers to delete?

Stop and remove all containers The following command is convenient if you want to stop/remove all the containers, including the running container. In this command, docker ps -a -q is used to display a list of IDs of all Docker containers, and docker rm is used to delete them.


Video Answer


2 Answers

Default limit of number of open files is 1024. You can increase it in two ways:

  1. Run the container with --ulimit parameter:

    docker run --ulimit nofile=5000:5000 <image-tag>
    
  2. Run the container with --privileged mode and execute ulimit -n 5000.

You can find more information here.

like image 138
mtyurt Avatar answered Oct 17 '22 11:10

mtyurt


It's more convenient to set the ulimit inside the docker systemD service

Modify /usr/lib/systemd/system/docker.service

ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_ADD_RUNTIMES --default-ulimit nofile=65535:65535
like image 3
vumdao Avatar answered Oct 17 '22 11:10

vumdao