systemd和systemctl在Ubuntu Docker的图像 [英] systemd and systemctl within Ubuntu Docker images

查看:1755
本文介绍了systemd和systemctl在Ubuntu Docker的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎 systemd 在Ubuntu Docker镜像中没有活动或可用。

It seems systemd is not active or available in Ubuntu Docker images.

我从 ubuntu运行Docker容器:16.04 ubuntu:16.10 图像。

如果我在中执行 systemctl status ssh 16,04 容器结果是错误无法连接到总线:没有这样的文件或目录。在 16.10 容器中,错误是 bash:systemctl:command not found

If I execute systemctl status ssh in the 16,04 container the result is the error Failed to connect to bus: No such file or directory. In the 16.10 container the error is bash: systemctl: command not found.

如果我执行 16.04 容器中找到systemctl systemctl,但不在 16.10 container。

If I do which systemctl systemctl is found in the 16.04 container but not in the 16.10 container.

我发现 / lib / systemd 存在。

我已尝试使用 apt-get install systemd libpam-systemd systemd-ui 安装systemd。然后哪个systemctl 16.10 中找到systemctl,但 systemctl status ssh 仍然给出错误无法连接到总线:没有这样的文件或目录

I have tried installing systemd with apt-get install systemd libpam-systemd systemd-ui. Then which systemctl finds systemctl in 16.10 but systemctl status ssh still gives the error Failed to connect to bus: No such file or directory

我的主要问题是:如何systemd和systemctl被激活以用于Ubuntu Docker映像?

My main question is: How can systemd and systemctl be activated for use in Ubuntu Docker images?

为什么在Ubuntu Docker容器中systemd没有活动?在实例化容器中是否使用systemd?

Why is systemd not active in Ubuntu Docker containers? Is systemd not used in instantiating the container?

我没有找到关于Ubuntu / Ubuntu Docker映像的这个主题的任何文档,只有关于Ubuntu从 Upstart systemd 。有没有任何文件提供完整的解释?

I have failed to find any documentation on this topic for Ubuntu / Ubuntu Docker images, only information on the Ubuntu transition from Upstart to systemd. Is there any documentation giving a full explanation?

推荐答案

这是设计。 Docker应该在容器的前台运行一个进程,它将在容器的pid命名空间中作为PID 1生成。 Docker设计用于进程隔离,而不是用于操作系统虚拟化,因此在容器(如systemd,cron,syslog等)内部没有其他操作系统进程和守护程序,只有您运行的entrypoint或命令。

This is by design. Docker should be running a process in the foreground in your container and it will be spawned as PID 1 within the container's pid namespace. Docker is designed for process isolation, not for OS virtualization, so there are no other OS processes and daemons running inside the container (like systemd, cron, syslog, etc), only your entrypoint or command you run.

如果它们包含了systemd命令,那么你会发现很多事情都不起作用,因为你的entrypoint替换了init。 Systemd还可用于停靠码头限制在容器内部的cgroup,因为更改cgroups的能力可能允许进程逃离容器的隔离。没有systemd作为init在容器内运行,没有后台程序来处理你的启动和停止命令。

If they included systemd commands, you'd find a lot of things not working since your entrypoint replaces init. Systemd also makes use to cgroups which docker restricts inside of containers since the ability to change cgroups could allow a process to escape the container's isolation. Without systemd running as init inside your container, there's no daemon to process your start and stop commands.

这篇关于systemd和systemctl在Ubuntu Docker的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆