【问题标题】:docker archlinux image: System has not been booted with systemd as init system (PID 1). Can't operatedocker archlinux 映像:系统尚未使用 systemd 作为 init 系统(PID 1)启动。无法操作
【发布时间】:2019-07-25 08:12:09
【问题描述】:

我正在使用来自 docker hub 的 archlinux/base 官方镜像。

我正在尝试使用 systemctl,它说。

$ docker run --rm -it ac16c4b756ed systemctl start httpd     
System has not been booted with systemd as init system (PID 1). Can't operate.

如何解决。

【问题讨论】:

    标签: docker archlinux systemctl


    【解决方案1】:

    好吧,“systemctl”本身不做任何事情,但它会要求 systemd 守护进程执行一些任务。它通常通过套接字与它通信。所以 systemd 守护进程必须已经启动。如果需要,有一些基础镜像会以 PID-1 的形式运行 systemd。

    但是,我个人不建议这样做。如果您确实需要坚持运行 systemctl 命令,那么您也可以尝试在该操作系统上使用 docker-systemctl-replacement 脚本。也可以作为容器的PID-1。

    【讨论】:

      【解决方案2】:

      如果您的目标是运行 Apache Web 服务器 (httpd),您应该使用 httpd image

      Docker 容器通常用于运行单个进程。因此,您通常不会设计一个容器来将 systemd 之类的东西作为根进程运行,然后将 httpd 作为子进程运行。您只需直接在前台运行 httpd。 httpd 图像执行此操作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-04-15
        • 1970-01-01
        • 2019-02-11
        • 1970-01-01
        • 2021-04-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多