简体   繁体   English

为什么Docker有一个守护进程?

[英]Why does Docker have a daemon?

I recently discovered rkt , a competitor container runtime to Docker. 我最近发现了rkt ,它是Docker的竞争对手容器运行时。 It seems like rkt does not need a daemon. 似乎rkt不需要守护进程。 For me, rkt is like running any other command and it works easily with systemd (or other init systems). 对我来说, rkt就像运行任何其他命令一样,它可以很容易地与systemd(或其他init系统)一起工作。

This makes me wonder about the utility of Docker's daemon. 这让我想知道Docker的守护进程的实用性。

Why does Docker need a daemon ? 为什么Docker需要一个守护进程? What does the daemon provide that would not be possible without it ? 守护进程提供了什么,没有它是不可能的? Is its only goal to remove the need for an init system like systemd (as can be seen in the Rancher OS) ? 它的唯一目标是不再需要像systemd那样的init系统(在Rancher操作系统中可以看到)?

Docker was designed as a client/server application which allows you to have remote access to the docker API. Docker被设计为客户端/服务器应用程序,允许您远程访问docker API。 This allows tools like the classic container based swarm that were effectively a reverse proxy to a cluster of docker hosts. 这允许像经典的基于容器的swarm这样的工具实际上是一个docker主机集群的反向代理。

The daemon also provides a place for shared state. 守护进程还为共享状态提供了一个位置。 It's restarting containers according to their restart policy. 它正在根据重启策略重启容器。 But it's also managing networks and volumes that may be shared between multiple containers. 但它也管理可在多个容器之间共享的网络和卷。

Lastly, with the introduction of swarm mode, the daemon is also the central location for these tools that would otherwise be run as their own daemons with tools like kubernetes. 最后,随着swarm模式的引入,守护进程也是这些工具的中心位置,否则它们将像kubernetes这样的工具作为自己的守护进程运行。

If you need a daemon-less solution but otherwise like docker, then consider using runc which is the runtime environment that docker uses for each container by default. 如果你需要一个无守护进程的解决方案,但是像docker那样,那么考虑使用runc ,它是docker默认为每个容器使用的运行时环境。

This doesn't involve the init inside the container. 这不涉及容器内的init。 If you need that, docker now includes an optional init that you can enable per container. 如果需要,docker现在包含一个可以为每个容器启用的可选init。 And you've always had the option to include your own init, like tini, if you needed something to cleanup zombie processes. 如果你需要清理僵尸进程的东西,你总是可以选择包含你自己的init,比如tini。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM