Docker Daemon is a core service and component of the Docker platform used to execute and manage its major components, like containers, images, networks, and volumes. The host is in charge of these components. Docker Daemon interacts with and executes containers. It also allocates resources and limits resource usage for containers to function properly.
If the containers must read and access many files or may be required to create new files, a low resource usage limit can cause serious problems, and the container may not function properly.
This blog will demonstrate how to double or increase the current ulimits of Docker Daemon.
How to Double the Current Ulimits of Docker Daemon?
Developers are sometimes required to increase the current ulimits of Docker Daemon to avoid unusual situations, such as being unable to create or open new files while running applications inside the container. To double or increase the ulimits of the Docker daemon, look at the listed steps.
Step 1: Check the Current Ulimits of Docker Daemon
First, run the container and check the default and currently set ulimits of Docker Daemon. For this purpose, we have created and run “go-cont” from “go-image”:
Here:
-
- “-d” option runs the container in detached mode.
- “–name” defines the container’s name:
- “go-image” is a Docker image created by Dockerfile instructions to dockerize the Golang program:
Check the container ulimit by utilizing the “docker exec -it <container-name> sh” command. This command will launch the container’s terminal. Utilize the “ulimit -n” command to check the current ulimits of Docker Daemon:
ulimit -n
The output shows that currently Docker ulimit is set as “2048”:
Step 2: Open Docker Settings
Open the Docker settings by clicking on the highlighted “Gear” icon:
Step 3: Visit Docker Engine Settings
Open the “Docker Engine” from the Docker settings menu. Here, you will find the default Daemon configurations in the “daemon.json” file as highlighted below:
Step 4: Double the Ulimits
After that, specify the following json format configurations. Here, you can see we have doubled the “Hard” and “Soft” ulimit of Docker daemon:
"nofile": {
"Hard": 4096,
"Name": "nofile",
"Soft": 4096,
}
}
After that, hit the “Apply & restart” button to save changes:
Step 5: Run the Container
Again, recreate and run the Docker container using the “docker run” command:
Step 6: Check Ulimits
Check the ulimit of the running container by executing the new command within a container using “docker exec” command. To check the ulimits of the Docker daemon, utilize the “ulimit -n” command:
ulimit -n
It can be observed that we have doubled the ulimits of the Docker Daemon.
Conclusion
To double the currently set ulimits in Docker Daemon, first, open up the Docker settings. Next, from the “Docker Engine” settings, modify the configuration settings of the “daemon.json” file. For this purpose, configure the “default-ulimits” for “nofile” and set the value of “Hard” and “Soft” ulimits of Docker Daemon. This write-up has illustrated how to double the current ulimits of Docker Daemon.