Docker 系统在构建时初始化

问题描述 投票:0回答:1

所以我想在 centOS 7 Docker 容器中安装并执行一个程序(ESET Endpoint Antivirus)。问题是我在运行之前明显无法安装它

/usr/sbin/init
.
这很烦人,因为我们不能
RUN /usr/sbin/init
在 Dockerfile 中,而我们应该能够在构建时通过 rpm 安装。这意味着我每次都需要在运行时安装(最多需要 2 分钟),并且由于我需要在每次任务后
--rm
我的容器,所以效率非常低。

如果我尝试使用

rpm -i /eea-9.1.4.0-el7.x86_64.rpm
作为命令参数运行容器,我得到
Failed to create bus connection: No such file or directory
.

有问题的部分在这里(

rpm -qp --scripts /eea-9.1.4.0-el7.x86_64.rpm
的输出):

preinstall scriptlet (using /bin/sh):
#!/bin/sh

# Script to be run before package is installed / upgraded

SYSTEMD_CAT="$(which systemd-cat 2>/dev/null || true)"
print_error() {
    errorstr="ESET Endpoint Antivirus error: $1"
    echo "$errorstr" 1>&2
    if [ -n "$SYSTEMD_CAT" ]; then
        printf "%s" "$errorstr" | $SYSTEMD_CAT -t "eea" -p err
    fi
}

# Check for UTF-8 support
if ! localectl list-locales | grep -i "UTF-8\|UTF8" 1>/dev/null ; then
    print_error 'UTF-8 support is not installed in the system. Please install a UTF-8 locale first. Aborting installation.'
    exit 1
fi

localectl list-locales
的调用返回上述总线错误。

如果我先运行

/usr/sbin/init
然后通过
exec
安装一切正常。

我已经广泛浏览了互联网,但没有找到令人满意的答案/替代方案,所以我在这里问。如果您知道在容器中使用基于 systemd 的操作系统的更有效方法,将不胜感激。
谢谢

docker dockerfile centos7 systemd
1个回答
0
投票

无需执行脚本即可安装。

rpm --no-scripts -i ...
© www.soinside.com 2019 - 2024. All rights reserved.