简体   繁体   English

docker-使用curl安装Java 8

[英]docker - installing java 8 with curl

To insall java 8 on docker container, I used this command in dockerfile 为了在Docker容器上安装Java 8,我在dockerfile中使用了此命令

RUN curl -LO 'http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.rpm'
-H 'Cookie: oraclelicense=accept-securebackup-cookie' RUN rpm -i jdk-8u111-linux-x64.rpm RUN rm jdk-8u111-linux-x64.rpm

It worked for awhile, but now this link is not no longer available. 它工作了一段时间,但现在此链接不再可用。 Is there replaceable url for this? 是否有可替换的网址? or easy way to insall java 8 on docker? 或在docker上安装Java 8的简单方法?

It's up to your using OS, so I'd like you to show your OS. 这取决于您使用的操作系统,所以我希望您展示您的操作系统。 For example, Ubuntu users prepares their ppa repository for Oracle Java. 例如,Ubuntu用户为Oracle Java准备其ppa存储库。

RUN add-apt-repository ppa:webupd8team/java
RUN apt-get update
RUN apt-get install oracle-java8-installer

It seems that Oracle has changed the authorization for downloading, the actual link that the browser uses is http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm?AuthParam=1496223138_c808095f7637d83147c37d69d3a87e7a , but this cannot be used with curl. 看来Oracle更改了下载授权,浏览器使用的实际链接是http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64 .rpm?AuthParam = 1496223138_c808095f7637d83147c37d69d3a87e7a ,但是不能与curl一起使用。

I have no solution for the problem with downloading from Oracle, but I use the official OpenJDK image as base and have found no problems with that. 对于从Oracle下载的问题,我没有解决方案,但我使用官方的OpenJDK映像作为基础,但没有发现任何问题。

If openjdk is OK for you, you can use 如果openjdk适合您,则可以使用

RUN apt-get install -y openjdk-8-jdk

openjdk, in contrast to oracle, does not require user's confirmation. 与oracle相比,openjdk不需要用户确认。

If you only need java runtime, consider openjdk-8-jre . 如果仅需要Java运行时,请考虑openjdk-8-jre

Adaption of my Dockerfile from https://hub.docker.com/r/sftech/java https://hub.docker.com/r/sftech/java改编我的Dockerfile

FROM ubuntu

ENV JAVA_VERSION=8

RUN echo oracle-java${JAVA_VERSION}-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
RUN apt-get update \
 && apt-get install -y software-properties-common \
 && apt-add-repository ppa:webupd8team/java \
 && apt-get update \
 && apt-get install -y oracle-java${JAVA_VERSION}-installer \
 && update-java-alternatives -s java-${JAVA_VERSION}-oracle \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/*

Why would you install java in an image / container, when you can get a java:8 image from the Docker store for free. 当您可以免费从Docker商店获取java:8映像时,为什么还要在映像/容器中安装java。 The license requirements are exactly the same as the java / jdk download install from the oracle.com website. 许可证要求与从oracle.com网站进行的java / jdk下载安装完全相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM