Docker and CentOS4

As much as we would want a world in which all applications were updated regularly and licensed sanely, that is not the world we live in. Some applications cost several hundreds of thousands of dollars (per seat!) and their users expect to be able to use them into the future, even after the vendor has moved on.

One solution to let these applications run and not have to keep older OS machines on your network is Docker. Docker does have a variety of base images available through their site, however typically they are newer OSes.

If you find yourself in the sad position of making a CentOS4 base image, here are some helpful pointers:

  1. CentOS4 used up2date to pull down system updates and new RPMS. However, it also supports Yum, and the CentOS4 repos do have a repodata folder for yum use. Grab the appropriate repodata folder, and put it in your /etc/yum.repos.d folder. Make sure to add a line for enabled=0.
  2. You will find the script here to be of particular value. I cut out the usage(), yum_config, and getops stuff.
  3. Add in a test to make sure $target exists. What if you accidentally kill off /tmp and then run the script and you forget to test for if $target exists? This exercise is left to the reader (but see #7)
  4. You will need to modify the first yum (...) install line to include --enablerepo=centos4 --disablerepo=*.
  5. Need extra packages? Make sure to copy in your repo definition from /etc/yum.repos.d to $target/etc/yum.repos.d as the the groupinstall will provide a repo that may not be what you want it to be.
  6. You will likely need to add in some important .i386/.i686 RPMs, especially if you are running the build script on a RHEL6 machine. Some good ones to include include libgcc and glibc.
  7. Kill off the RPM repository.1 rm -Rf $target/var/lib/rpm -- the reason for this is that you are likely running this on a newer RHEL machine. Older versions of RPM will not be able to read the RPM database that you have created. If you really need the ability to do development and install RPMs in a docker repo to figure out what you need, after you have built a base image, run rpm --initdb and re-run your groupinstall command. Then, tar the RPM library and put it into the script so that you may experiment without having to perform this step manually. I do suggest that once you are done with dev, you just kill off the RPM library to begin with -- no one should be installing RPMs inside your artisanal container, right?
  8. Since you know your OS name, it may be beneficial to just set name=centos up front.
  9. Bam. You have a CentOS4 image now!

There are arguments to be made for being able to use yum in a Dockerfile however, given that only one application i know of needs to be run like this, I find that building this once and keeping the scripts in revision control work well enough for me.

My Dockerfile is fairly simple - I have a FROM and MAINTAINER line, with an ADD and an ENTRYPOINT - the ADD simply drops in an init script that adds a local-to-container user with the appropriate uid/gid, then switches to that user and runs the application. X11 use is handled by proper management of the DISPLAY variable and/or by exposing /tmp/X11-Unix to the container.

Hopefully you find yourself not needing to support older apps. But, in the event you do, maybe this will help.


  1. katzj notes that he has a solution to this. See his tweet for more info.