Howto create a Docker Image for RHEL
RHEL docker images are not available from Docker Hub. It’s available from Redhat docker registry and the catalog can be accessedhere. However there could be cases where you might want to create a RHEL docker image from scratch. The following steps will guide you to create a RHEL docker image from scratch. While these steps are for creating RHEL 7.1 LE docker image on PowerPC servers, the same can be applied for creating RHEL docker image on Intel servers as well.
The steps below have been performed on an Ubuntu 15.10 OS running as a PowerKVM guest. However you can run the same steps on RHEL or Fedora as well.
Pre-requisites
Access to RHEL package repository. You can use a local repository created from RHEL installation ISO as described below
Install ‘yum’ package. This is not required on a RHEL or Fedora system as it’ll be there by default.
Steps to create a RHEL docker image
Create a new RPM root directory
Initialize the new RPM root directory# rpm --root ${rpm_root} --initdb
The rest of the install instructions will use this new RPM root as the install destination for a minimalistic RHEL OS.
Install the redhat-release-server rpm package for RHEL 7.1 LE
Configure yum repositories as required.
For example if you want to use only the local repository, then do the following
rpmdb: /var/lib/rpm/Name: unexpected file type or format
Indeed, it’s a corrupt rpm database. Steps to resolve:
- Check for processes holding the rpm database open (usually in MUTEX/FUTEX states):
If it finds any, kill -9 them all.
- Delete any temporary DB files:
- Rebuild your RPM database:
If you still have problems, a reboot is probably quickest, then repeat steps 2 and 3 above.
If you encounter ‘No such file or directory’ error, then you’ll need to create the /etc/yum.repos.d directory.Import GPG keys
Install minimalistic RHEL OS
This will install a minimalistic RHEL OS under /rhel7-root
Additional Customization
Chroot to the new RHEL installation and perform any additional customizations if required
Convert this RHEL installation to a docker image
Use the new RHEL docker image
Once you have created the RHEL docker image, you can push it to your local registry for sharing. Hope this will be of some help to you in your docker journey.
oracle,linux