9

I am creating a dockerfile that runs a custom application that is tied to a specific version of Java.

I'm using a centos7 base image because that's what an article I was referring to was using and because I have to use something, so that's as good as any. I honestly don't care what userland I'm using. The point of this image is the software being hosted, the Linux distribution itself is just a means to an end - importantly, the JDK will not be used by other applications or users.

As stated, my application is tied to the specific version of Java that I am using - any update to the Java version will require a full regression test of the software with that specific version before it is released.

The article I was following started out with the relevant dockerfile JDK install parts looking like this:

FROM centos:centos7
RUN yum makecache \
    && yum update -y \
    && yum install -y \
    java-1.8.0-openjdk-devel \
    && yum clean all

That's not specific enough, any time the images is build it will get a random version of Java, which is not what I want, I need a specific version of Java.

I changed the docker file to look like this:

FROM centos:centos7
RUN yum makecache \
    && yum update -y \
    && yum install -y \
    java-1.8.0-openjdk-devel-1.8.0.65-3.b17.el7 \
    && yum clean all

And the docker image was building fine. That was in December.

This week, I needed to make a small change to a different part of the software and rebuild a new version of the image, but the image build now fails.

The build fails now because that specific version of the java package is no longer available (at least, I think that's what it's telling me):

Error: Package: 1:java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64 (base)
Requires: java-1.8.0-openjdk-headless = 1:1.8.0.65-3.b17.el7
Available: 1:java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64 (base)
java-1.8.0-openjdk-headless = 1:1.8.0.65-3.b17.el7
Installing: 1:java-1.8.0-openjdk-headless-1.8.0.71-2.b15.el7_2.x86_64 (updates)
java-1.8.0-openjdk-headless = 1:1.8.0.71-2.b15.el7_2

How can I rebuild my dockerfile so that I can always use a specific version of Java (in this example, I want the version of java to be 1.8.0 update 65)?

A negative answer is fine - if the various Linux packaging mechanisms in general don't want people to use their repositories like this, that's Ok - I can always package my own version of the JDK as a zip file and just unpack that somewhere inside the environment as part of the image build, but that's a bunch of hassle that I'd prefer not to have to do.

How do other people do this? Is there a different way of installing the JDK so that I can have a recent version of the OS distribution with latest updates (as defined by the base image in the FROM clause and the yum update) but install a specific version of the JDK?

Is there a Linux version more suited to this kind of requirement (I'm not wedded to CentOS, the userland Linux distribution is not particularly important to me)?

Shorn
  • 235
  • 1
  • 6
  • Would [yum-versionlock](http://linux.die.net/man/1/yum-versionlock) by usable with Docker? – Aaron Copley Feb 18 '16 at 02:11
  • 1
    @AaronCopley I don't think so. versionlock appears to be focused on making sure the version stays where it is the next time you run update - but I'm actually concerned about making the initial install command not fail once the repository has moved on to a new version. I don't plan on ever running yum update on that particular environment ever again. When the environment needs new updates, a new docker image will be built (and I want that image to be using the exact same version of the JDK as it's using now). – Shorn Feb 18 '16 at 02:57
  • 1
    Sorry, I think I misunderstood. You can see the version you are requesting is in *base* and it's installing from *updates* for whatever reason. Try `yum install -y $package --disablerepo=updates` – Aaron Copley Feb 18 '16 at 03:20
  • 1
    @AaronCopley Yep, that seems to work - thanks! If you make it an answer I'll mark it successful. Or I'll add it myself later. – Shorn Feb 18 '16 at 06:13

1 Answers1

2

It looks like it sees the package you want, but for whatever reason is installing from the updates repository.

You can disable the updates repository in your yum command;

yum install -y $package --disablerepo=updates
Aaron Copley
  • 12,345
  • 5
  • 46
  • 67