10.4.2. 使用 Red Hat Satellite 订阅构建 Docker
Docker 策略构建可以使用 Red Hat Satellite 软件仓库来安装订阅内容。
先决条件
- 必须将权利密钥和 Satellite 存储库配置添加为构建输入。
流程
使用以下示例 Dockerfile 来通过 Satellite 安装内容:
FROM registry.redhat.io/rhel7:latest
USER root
# Copy entitlements
COPY ./etc-pki-entitlement /etc/pki/entitlement
# Copy repository configuration
COPY ./yum.repos.d /etc/yum.repos.d
# Delete /etc/rhsm-host to use entitlements from the build container
RUN sed -i".org" -e "s#^enabled=1#enabled=0#g" /etc/yum/pluginconf.d/subscription-manager.conf 1
#RUN cat /etc/yum/pluginconf.d/subscription-manager.conf
RUN yum clean all
#RUN yum-config-manager
RUN rm /etc/rhsm-host && \
# yum repository info provided by Satellite
yum -y update && \
yum -y install <rpms> && \
# Remove entitlements
rm -rf /etc/pki/entitlement
# OpenShift requires images to run as non-root by default
USER 1001
ENTRYPOINT ["/bin/bash"]
- 1
- 如果使用
enabled=1
在构建中添加 Satellite 配置失败,请将RUN sed -i".org" -e "s#^enabled=1#enabled=0#g" /etc/yum/pluginconf.d/subscription-manager.conf
添加到 Dockerfile。