【发布时间】:2020-04-15 09:18:03
【问题描述】:
我的 Docker 容器上运行了一个 Ubuntu 18.04 映像。我登录并安装了 Openresty。还安装了 systemd。当我使用命令“systemctl”时出现此错误:
System has not been booted with systemd as init system (PID 1). Can't operate.
我该如何解决?
【问题讨论】:
-
作为两条一般规则,您不应该在正在运行的容器中安装软件(一旦您的容器退出它就会丢失),并且像
systemctl这样的命令在 Docker 中不起作用。你可能会认为 Docker 是一种打包应用程序的方式,而不是一个带有初始化系统、用户和进程的成熟虚拟机; Docker 的 Containerizing an application 教程介绍了一个基本的标准用例。