如何在docker debian上安装oracle-java8-installer:jessie

时间:2018-01-17 12:32:42

标签: docker java-8 debian debian-jessie

我正在尝试通过oracle-java8-installer在debian:jessie docker容器上安装java 8。以下是我的Dockerfile:

FROM debian:jessie

ENV JAVA_VERSION 1.8.0

RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" > /etc/apt/sources.list.d/webupd8team-java.list
RUN echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" >> /etc/apt/sources.list.d/webupd8team-java.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
RUN echo "debconf shared/accepted-oracle-license-v1-1 select true" | /usr/bin/debconf-set-selections
RUN apt-get update
RUN apt-get install -y --force-yes vim
RUN apt-get install -y --force-yes oracle-java8-installer

然而这给了:

Connecting to download.oracle.com (download.oracle.com)|23.63.224.171|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-01-17 12:31:05 ERROR 404: Not Found.

download failed
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)
The command '/bin/sh -c apt-get install -y --force-yes oracle-java8-installer' returned a non-zero code: 100

我发现在线描述了许多类似的问题,但所提出的解决方案都不适用于我。有什么想法吗?

5 个答案:

答案 0 :(得分:8)

https://hub.docker.com/r/anapsix/docker-oracle-java8/~/dockerfile/上找到了解决方案:

public void Start()
{

    List<String> list = new List<String>(File.ReadAllLines("urls.txt"));

    int maxThreads = 100;
    var framework = new Sender();

    ThreadPool.SetMinThreads(maxThreads, maxThreads);

    Parallel.ForEach(list, new ParallelOptions { MaxDegreeOfParallelism = maxThreads }, delegate (string url)
    {

        framework.Send(url, "proxy:port");

    });

    Console.WriteLine("Done.");

}

您要查找的“秘密调味料”是第一行:

## JAVA INSTALLATION
RUN echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" > /etc/apt/sources.list.d/webupd8team-java-trusty.list
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes --no-install-recommends oracle-java8-installer && apt-get clean all

答案 1 :(得分:7)

关于donhector的回复和你的问题:你需要替换安装程序文件中的字符串,而不是你的上一个命令:

apt-get install -y --force-yes oracle-java8-installer

运行以下命令:

apt-get -y install oracle-java8-installer || true
cd /var/lib/dpkg/info

sed -i 's|JAVA_VERSION=8u151|JAVA_VERSION=8u162|' oracle-java8-installer.*
sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/|' oracle-java8-installer.*
sed -i 's|SHA256SUM_TGZ="c78200ce409367b296ec39be4427f020e2c585470c4eed01021feada576f027f"|SHA256SUM_TGZ="68ec82d47fd9c2b8eb84225b6db398a72008285fafc98631b1ff8d2229680257"|' oracle-java8-installer.*
sed -i 's|J_DIR=jdk1.8.0_151|J_DIR=jdk1.8.0_162|' oracle-java8-installer.*

apt-get install -f -y
apt-get install -y oracle-java8-set-default

我将它们放在一个单独的脚本中并将其作为

运行
RUN /bin/sh /path/to/script.sh

或者您可以直接从Dockerfile运行它们,这取决于您。

答案 2 :(得分:5)

您正在从webupd8 PPA回购安装。如果您注意到,该repo中的Java 8包指向Java 8版本151。该软件包从Oracle服务器中提取151的二进制文件(因为Java Oracle许可证不允许任何其他人托管二进制文件)。 Oracle几天前发布了版本161,显然已从其服务器中移动或删除了151。所以基本上webupd8 PPA repo中的包试图下载151二进制文件,该二进制文件不再存在于webupd8软件包所期望的位置(因此得到了404)。 webupd8 PPA repo维护者必须发布一个新的包,指向Oracle的新161二进制文件。 Docker或Debian在这个问题上没有任何作用,它基本上是一个破碎的链接问题。

在此之前,您可以应用&#34;解决方法&#34;就像这里提到的那样:JDK 8 is NOT installed - ERROR 404: Not Found

这是webupd8 repo中的Java包列表:

https://launchpad.net/~webupd8team/+archive/ubuntu/java/+packages

答案 3 :(得分:2)

dpkg oracle Jdk error while installing cassandra in Ubuntu 16.04。使用任何类型的安装脚本的每个人都会遇到此问题。

答案 4 :(得分:0)

** Java 11:

RUN apt-get install wget java-common gnupg2 -y
RUN echo "oracle-java11-installer shared/accepted-oracle-license-v1-2 select true" | debconf-set-selections
RUN echo "deb http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic main" | tee /etc/apt/sources.list.d/linuxuprising-java.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 73C3DB2A
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends oracle-java11-installer && apt-get clean all