最好的做法是在停泊码头内守护进程吗? [英] Is it best practice to daemonize a process within docker?
问题描述
bundle exec sidekiq -d
然而,随着Docker的建立,我发现自己只是执行命令,如果进程停止或突然退出,整个docker容器poofs和一个新的旋转 - 基本上是守护进程的一个点,并观察它(所有STDOUT都被发送到CloudWatch / Elasticsearch进行监视)。
我觉得这样也会在Docker容器中重新执行单个进程的想法,如果您的守护程序倾向于在我看来会倾向于违反该通用标准。
是否存在任何最佳实践文档,即使您只在容器内运行一个进程。
您不守护程序
-d
通常见于 docker run -d
命令,使用分离(不守护程序)模式,其中docker容器将在后台运行,完全与当前shell分离。
为了在容器中运行多个进程,背景人员将成为主管。
请参阅在Docker中使用主管(或最近的 docker --init
) 。
Many best practice guides emphasize making your process a daemon and having something watch it to restart in case of failure. This made sense for a while. A specific example can be sidekiq.
bundle exec sidekiq -d
However, with Docker as I build I've found myself simply executing the command, if the process stops or exits abruptly the entire docker container poofs and a new one is automatically spun up - basically the entire point of daemonizing a process and having something watch it (All STDOUT is sent to CloudWatch / Elasticsearch for monitoring).
I feel like this also tends to re-enforce the idea of a single process in a docker container, which if you daemonize would tend to in my opinion encourage a violation of that general standard.
Is there any best practice documentation on this even if you're running only a single process within the container?
You don't daemonize a process inside a container.
The -d
is usually seen in the docker run -d
command, using a detached (not daemonized) mode, where the the docker container would run in the background completely detached from your current shell.
For running multiple processes in a container, the background one would be a supervisor.
See "Use of Supervisor in docker" (or the more recent docker --init
).
这篇关于最好的做法是在停泊码头内守护进程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!