Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ozbillwang/db1d59104b54254cfd0f18d3ad4ca3d6 to your computer and use it in GitHub Desktop.

Select an option

Save ozbillwang/db1d59104b54254cfd0f18d3ad4ca3d6 to your computer and use it in GitHub Desktop.
The way to build red hat base docker image without subscription managed registered.

In redhat, if you need build container from base image, for example, registry.access.redhat.com/rhel7/rhel:7.3-53 (free download from https://access.redhat.com/containers) You have to build this image on a red hat server with subscription managed registered.

Here is the way to bypass the check and you can build docker image on any redhat 7 server.

make sure the package has been installed

yum install rh-amazon-rhui-client

list the package files

$ rpm -ql rh-amazon-rhui-client
/etc/init.d/choose_repo
/etc/init.d/rh-cloud-firstboot
/etc/pki/rhui/cdn.redhat.com-chain.crt
/etc/pki/rhui/content-rhel7.key
/etc/pki/rhui/product/content-rhel7.crt
/etc/pki/rhui/product/rhui-client-config-server-7.crt
/etc/pki/rhui/rhui-client-config-server-7.key
/etc/yum.repos.d/redhat-rhui-client-config.repo
/etc/yum.repos.d/redhat-rhui.repo
/etc/yum.repos.d/rhui-load-balancers.conf
/etc/yum/pluginconf.d/amazon-id.conf
/etc/yum/pluginconf.d/rhui-lb.conf
/usr/lib/yum-plugins/amazon-id.py
/usr/lib/yum-plugins/amazon-id.pyc
/usr/lib/yum-plugins/amazon-id.pyo
/usr/lib/yum-plugins/rhui-lb.py
/usr/lib/yum-plugins/rhui-lb.pyc
/usr/lib/yum-plugins/rhui-lb.pyo
/usr/sbin/choose_repo.py
/usr/sbin/rh-cloud-firstboot.py

copy above files to local.

rpm -ql rh-amazon-rhui-client |tar cvf package.tar -T -
tar xvf  package.tar 
rm  package.tar

Prepare Dockerfile

FROM registry.access.redhat.com/rhel7/rhel:7.3-53

COPY etc /etc
COPY usr /usr

RUN yum -y update; yum clean all

Build the image

docker build -t rhel7-base . 

Now you still see below message, but yum update will continoue.

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

@karthik101

Copy link
Copy Markdown

I tried this same to RHEL7 atomic minimal image but it cant resolve the rhui hostname. This image uses "microdnf" instead of "yum". I'm not sure how to provide credentials from host to the container.

@next-carlosleon

Copy link
Copy Markdown

Same as @karthik101

@sambanks

Copy link
Copy Markdown

Thanks mate, lifesaver!!

We didn't have to copy /usr though, just /etc/yum and /etc/yum.repos.d

@ksummersill2

Copy link
Copy Markdown

Awesome; thanks!

@EdwardJ1n

Copy link
Copy Markdown

Dude, this is awesome. It makes my day. [thumbs up]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment