Docker 作为构建者,无法安装 systemd 头文件

Docker as a builder, can't install systemd header files

我正在尝试根据官方 CentOS7 映像更新 Docker 映像。它用作 Node.js 个项目的生成器。

我需要添加 systemd-devel 包来编译一些依赖项,但这失败并出现以下错误:

fakesystemd-1-17.el7.centos.noarch has installed conflicts systemd: fakesystemd-1-17.el7.centos.noarch

谢谢

fakesystemd 是 CentOS Docker 镜像中的一个特殊包,它满足了对 Systemd 的依赖,而无需实际安装 Systemd(毕竟你通常不需要在容器内安装 init 系统) . yum info fakesystemd 说得更多:

Minimal docker-specific package to satisfy systemd Provides: without installing systemd in Docker images. It is intended strictly for use in Docker images/containers. It doesn't provide any functionality from systemd package - it only contains few important directories and files. fakesystemd is definitely not applicable for full bootable operation system!

To install the real systemd in the image you need to run yum swap command in this form:

yum swap -- remove fakesystemd -- install systemd systemd-libs

您需要将 fakesystemd 软件包替换为“真正的”systemd 软件包,然后还可以安装 systemd-devel:

RUN yum swap -y fakesystemd systemd && \
    yum install -y systemd-devel