如何在基于CentOS的Dockerfile中定义OpenJDK 8? [英] How to define OpenJDK 8 in CentOS based Dockerfile?

查看:243
本文介绍了如何在基于CentOS的Dockerfile中定义OpenJDK 8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设有一个CentOS Dockerfile:

Assuming that there is a CentOS Dockerfile:

FROM centos

为其添加OpenJDK 8的正确方法是什么?

What is the right way of adding OpenJDK 8 for it ?

我尝试使用与Fedora类似的方法

I have tried to use similar approach as for Fedora https://github.com/projectatomic/docker-fedora-images/blob/master/java-openjdk-8/Dockerfile

但是,当我运行映像时,java版本是"1.7.0_111" ,即使预期是JDK 8:

But when I run the image java version is "1.7.0_111", even though it is expected to be JDK 8:

docker run -i -t <image> /bin/bash

[user@2fcc1e47c3cd projects]$ java -version

java version "1.7.0_111"
OpenJDK Runtime Environment (rhel-2.6.7.2.el7_2-x86_64 u111-b01)
OpenJDK 64-Bit Server VM (build 24.111-b01, mixed mode)

有许多描述Oracle JDK安装的资料,但是我找不到关于OpenJDK的任何相关说明

There are many sources which describe Oracle JDK installations, but I was not able to find any relevant instructions for OpenJDK

推荐答案

似乎很简单:

FROM centos

RUN yum install -y \
       java-1.8.0-openjdk \
       java-1.8.0-openjdk-devel

ENV JAVA_HOME /etc/alternatives/jre
.
.

这篇关于如何在基于CentOS的Dockerfile中定义OpenJDK 8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆