2.10.3. 使用 Subscription Manager 运行构建
2.10.3.1. 使用 Subscription Manager 执行 Docker 构建
Docker 策略构建可以使用 Subscription Manager 来安装订阅内容。
先决条件
必须添加授权密钥、Subscription Manager 配置和 Subscription Manager 证书颁发机构,作为构建输入。
流程
使用以下示例 Dockerfile 来通过 Subscription Manager 安装内容:
FROM registry.redhat.io/rhel7:latest USER root # Copy entitlements COPY ./etc-pki-entitlement /etc/pki/entitlement # Copy subscription manager configurations COPY ./rhsm-conf /etc/rhsm COPY ./rhsm-ca /etc/rhsm/ca # Delete /etc/rhsm-host to use entitlements from the build container RUN rm /etc/rhsm-host && \ # Initialize /etc/yum.repos.d/redhat.repo # See https://access.redhat.com/solutions/1443553 yum repolist --disablerepo=* && \ subscription-manager repos --enable <enabled-repo> && \ yum -y update && \ yum -y install <rpms> && \ # Remove entitlements and Subscription Manager configs rm -rf /etc/pki/entitlement && \ rm -rf /etc/rhsm # OpenShift requires images to run as non-root by default USER 1001 ENTRYPOINT ["/bin/bash"]