RedHat UBI 8安装期望软件包

问题描述

我有expect脚本,需要在RedHat UBI 8容器下运行。我正在尝试通过快照包管理器安装Expect,但是启动快照时出现问题。 发出systemctl enable --now snapd.socket后,我得到:

System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

是否可以expect毫无快照地安装到RedHat UBI 8中?

到目前为止,我的Dockerfile:

FROM registry.access.redhat.com/ubi8/ubi

RUN dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y && \
    dnf install http://rpms.remirepo.net/enterprise/remi-release-8.rpm -y && \
    dnf update -y && \
    dnf install -y wget && \
    wget http://mirror.centos.org/centos/6/os/x86_64/Packages/squashfs-tools-4.0-5.el6.x86_64.rpm && \
    dnf install squashfs-tools-4.0-5.el6.x86_64.rpm -y && \
    wget http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/bash-completion-2.7-5.el8.noarch.rpm && \
    dnf install -y bash-completion-2.7-5.el8.noarch.rpm && \
    dnf install snapd -y && \
    systemctl enable --now snapd.socket && \
    ln -s /var/lib/snapd/snap /snap && \
    snap install expect

解决方法

expect软件包是基本rhel 8存储库的一部分。如果您的主机具有有效的RHEL订阅,则您的容器应有权访问所有RHEL 8存储库,这意味着您可以简单地在容器内安装expect

dnf -y install expect

如果您没有有效的订阅,也许只是使用基于CentOS的映像?


最简单的解决方案是(a)使用基本映像而不使用许可限制,或(b)购买所用软件的许可证。如果您的客户不愿意做任何事情,那么您可以选择以下方法:

您可以在ubi下使CentOS存储库可用。创建指向CentOS 8存储库的存储库配置:

[centos8-base]
name = CentOS 8 Base OS
baseurl = http://mirror.centos.org/centos/8/BaseOS/x86_64/os/
gpgcheck = 0
enabled = 0

并使用它来安装期望:

FROM registry.access.redhat.com/ubi8/ubi

COPY centos8.repo /etc/yum.repos.d/centos8.repo
RUN dnf -y --enablerepo=centos8-base install expect

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...