大网数据广告活动
服务器运维问答

How do I build a Linux environment that specifies specific versions of packages?

· 52CE 我爱测

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,…

问题原文

原帖链接 · Shorn · CC BY-SA 3.0

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)?

已采纳解答

原帖链接 · Aaron Copley · CC BY-SA 3.0

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-02-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。