My main developer box is running Centos8. I'm working on a project where I need to do some builds on RHEL7/8/9. I have docker installed on the host and pulling RHEL7 image from registry.redhat.io/rhel7:7.9-702.1655292978
, RHEL8 from docker hub (redhat/ubi8:latest
) and RHEL9 also from docker hub (redhat/ubi9:latest
). RHEL 7/8 work without issue but RHEL9 has the error:
subscription-manager is disabled when running inside a container. Please refer to your host system for subscription management.
I have a valid subscription but for some reason, it is not possible to actually run a RHEL9 image from a non RHEL host. I'm not sure I understand the reason for this but is there a workaround (other than changing the host to RHEL) so that I can register my RHEL9 container?
Someone in my team found a solution. The article https://access.redhat.com/solutions/5870841 basically points to injecting the subscription info (from a registered system) into the container.
Here is a sample docker file I used:
FROM registry.redhat.io/ubi9/ubi
COPY rhel9_sub/redhat.repo /run/secrets/redhat.repo
COPY rhel9_sub/rhsm /run/secrets/rhsm
COPY rhel9_sub/entitlement /run/secrets/etc-pki-entitlement
where the rhel9_sub folder I was copying from came from my registered RHEL9 host.
I can now query the repo and pull kernel packages into the container without issue.