docker 设置 ulimit

一、 通过docker run –ulimit 参数设置这个容器的 ulimit 值

docker run --ulimit nofile=1024:1024 --rm debian sh -c "ulimit -n"

二、通过配置 daemon.json 配置默认值

配置nofile

{
        "default-ulimits": {
                "nofile": {
                        "Name": "nofile",
                        "Hard": 64000,
                        "Soft": 64000
                }
        }
}

配置core

{
       "default-ulimits": {
			"core": {
			"Name": "core",
			"Hard": 0,
			"Soft": 0
		}
}
}

systemctl daemon-reload
systemctl restart docker

文档: https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file

posted @ 2024-01-16 12:16  EJW  阅读(781)  评论(0编辑  收藏  举报