4

I'm attempting to use RHEL 9 via the redhat/ubi9 Docker image, having redhat individual developer subscription. However, on attempt to use subscription-manager, got this error message: subscription-manager is disabled when running inside a container. Please refer to your host system for subscription management.. Am I supposed to configure something on macOS level, or configure in container itself?

For RHEL 8 image (redhat/ubi8) everything works well.

2 Answers2

5

All you need is just a return False from in_container(), See https://github.com/candlepin/subscription-manager/blob/subscription-manager-1.28.32-1/src/rhsm/config.py#L105-L114:

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

ARG REDHAT_USERNAME
ARG REDHAT_PASSWORD

RUN sed -i 's/\(def in_container():\)/\1\n    return False/g' /usr/lib64/python*/*-packages/rhsm/config.py
RUN subscription-manager register --username $REDHAT_USERNAME --password $REDHAT_PASSWORD --auto-attach
RUN yum update -y
RUN subscription-manager unregister
FROM registry.access.redhat.com/ubi8/ubi

ARG REDHAT_USERNAME
ARG REDHAT_PASSWORD

RUN sed -i 's/\(def in_container():\)/\1\n    return False/g' /usr/lib64/python*/*-packages/rhsm/config.py
RUN subscription-manager register --username $REDHAT_USERNAME --password $REDHAT_PASSWORD --auto-attach
RUN yum update -y
RUN subscription-manager unregister
FROM registry.access.redhat.com/ubi9/ubi

ARG REDHAT_USERNAME
ARG REDHAT_PASSWORD

RUN sed -i 's/\(def in_container():\)/\1\n    return False/g' /usr/lib64/python*/*-packages/rhsm/config.py
RUN subscription-manager register --username $REDHAT_USERNAME --password $REDHAT_PASSWORD --auto-attach
RUN yum update -y
RUN subscription-manager unregister
1

For RHEL 8 image (redhat/ubi8) everything works well.

It looks like redhat updated ubi8 too, same problem occurs with 8.7-929. 8.6-990 is working okay, for now downgrading to that one is a possible workaround.

Unfortunately, Redhat changed the way subscription managers work in containers: See their official documentation on running ci/cd inside ubi containers

Thread on redhat forums discussing this change:

Someone mentioned using ENV SMDEV_CONTAINER_OFF=1 In the dockerfile for a possible workaround. That didn't work for ubi8, maybe you can try for ubi9 and see it it fixes it. Unfortunately, this is also just a workaround... as far as I can see, the only real fix is to run the container on a registered RHEL machine (since the container now takes the subscription info from the host).

This really is a shame, redhat basically butchered the ubi images with this move... Having a container be bound to a specific host OS seems like a really bad idea.

  • 1
    [`SMDEV_CONTAINER_OFF` is only available starting with subscription-manager 1.29.14](https://access.redhat.com/discussions/5889431#comment-2354194). But [Wong Hoi Sing Edison's answer](https://serverfault.com/a/1116296/58568) seems to work in the meantime. – bmaupin Feb 16 '23 at 18:05