Using yum with registry.access.redhat.com Images: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
=Internal=
=Internal=
* [[Registry.access.redhat.com#Using_yum_with_registry.access.redhat.com_Images|registry.access.redhat.com]]
* [[Registry.access.redhat.com#Using_yum_with_registry.access.redhat.com_Images|registry.access.redhat.com]]
* [[Yum#Adding_a_Repository_Definition|yum | Adding a Repository Definition]]


=Overview=
=Overview=
Line 32: Line 33:
Use the following Dockerfile fragment:
Use the following Dockerfile fragment:


...
  COPY ./entitlements/redhat.repo /etc/yum.repos.d/redhat.repo
  COPY ./entitlements/redhat.repo /etc/yum.repos.d/redhat.repo
  COPY ./entitlements/00000000000000000-key.pem /etc/pki/entitlement/00000000000000000-key.pem
  COPY ./entitlements/00000000000000000-key.pem /etc/pki/entitlement/00000000000000000-key.pem
Line 39: Line 41:
  USER root
  USER root
  RUN yum -y install crontabs && rm /etc/pki/entitlement/*.pem
  RUN yum -y install crontabs && rm /etc/pki/entitlement/*.pem
...
Build:
docker build -t docker.io/something/else:latest .

Latest revision as of 19:08, 18 April 2021

External

Internal

Overview

registry.access.redhat.com images may need at times additional components installed with yum. However, they do not come pre-configured with any repository yum may use, so it fails with:

This article describes the procedure to configure the image with the appropriate repositories and entitlements, so yum can be used. Note that entitlements required to access the RPM repository in question are necessary.

Procedure

Prepare a yum repository file. It can be conventionally named redhat.repo. It should list the repositories that contains the dependencies that are needed. A commonly used repository is "rhel-7-server-extras-rpms":

[rhel-7-server-extras-rpms]
name = Red Hat Enterprise Linux 7 Server - Extras (RPMs)
baseurl = https://cdn.redhat.com/content/dist/rhel/server/7/7Server/$basearch/extras/os
ui_repoid_vars = basearch
metadata_expire = 86400
sslverify = 1
enabled = 1
gpgcheck = 1
sslclientkey = /etc/pki/entitlement/00000000000000000-key.pem
sslclientcert = /etc/pki/entitlement/00000000000000000.pem
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
sslcacert = /etc/rhsm/ca/redhat-uep.pem

Place redhat.repo into a local ./entitlements directory.

Gather entitlements (/etc/pki/entitlement/00000000000000000-key.pem, /etc/pki/entitlement/00000000000000000.pem) and various other cryptographic artifacts (/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release and /etc/rhsm/ca/redhat-uep.pem) from a system that has them and place them into a local ./entitlements directory.

Use the following Dockerfile fragment:

...
COPY ./entitlements/redhat.repo /etc/yum.repos.d/redhat.repo
COPY ./entitlements/00000000000000000-key.pem /etc/pki/entitlement/00000000000000000-key.pem
COPY ./entitlements/00000000000000000.pem /etc/pki/entitlement/00000000000000000.pem
COPY ./entitlements/RPM-GPG-KEY-redhat-release /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
COPY ./entitlements/redhat-uep.pem /etc/rhsm/ca/redhat-uep.pem
USER root
RUN yum -y install crontabs && rm /etc/pki/entitlement/*.pem
...

Build:

docker build -t docker.io/something/else:latest .