增加 Ghost 的 PID Docker

Increase PIDs of Ghost Docker

我正在使用 Docker 的 Ghost 博客,但我的站点的用户访问量过多。 当我查看容器的统计信息时,Ghost 只提供 10 个 pid,而不是更多。

那么,如何在 ghost docker 容器中增加更多 pid?

我会回答你的问题"how to increase PIDs in Docker"但我不认为你的问题来自这个限制。

如果您想增加任何 Docker 容器的 PID 限制,您可以使用 --pids-limit 选项,因为 Docker Engine 1.11。可以找到文档 here, in the docker run documentation from docs.docker.com.

它说:

--pids-limit        Tune container pids limit (set -1 for unlimited)

您必须使用此选项重新启动您的容器。通过重新启动,我的意思是删除它然后重新启动它(确保您不会丢失任何数据)。

限制PID是有原因的,比如避免fork bomb。但限制不是 10 个 PID,而是 512 个(实际数量可能会发生变化):

This is a new cgroup to limit the number of processes that can be forked inside a cgroup. It shipped in the 4.3 kernel.

We decided to make this feature secure by default, meaning we are setting the PIDs Limit for the docker cgroup parent to 512 (actual number may change but something along these lines), more than enough for the average user, but not enough to do great harm.

Of course if you need more you can override the default, or even set it as unlimited.

[...]

See how easy it is to prevent a fork bomb with --pids-limit for a container.

- Docker Engine 1.10 Security Improvements, by Jessie Frazelle on 02/04/2016, Docker Blog