Docker: 如何在 Debian jessie-slim 上安装 OpenJDK JRE 12?

Docker: How to install OpenJDK JRE 12 on top of Debian jessie-slim?

我正在尝试在 debian:jessie-slim 图像之上安装 OpenJDK JRE 12。

最后,我需要安装openjdk-12-jre-headless包。但是,我得到:

E: The value 'openjdk-12-jre-headless' is invalid for APT::Default-Release as such a release is not available in the sources

我尝试了不同的选择,但看起来我做错了什么。

我的 Dockerfile 相当复杂,但这个问题可以重现:

FROM debian:jessie-slim
RUN apt-get install -y --target-release openjdk-12-jre-headless

好的,我设法在您提供给定 Dockerfile 的图像上安装了这个 jre 发行版:

FROM debian:jessie-slim
RUN apt-get update && \
 apt-get -y upgrade && \
 echo 'deb http://ftp.de.debian.org/debian sid main' >> '/etc/apt/sources.list' && \
 apt-get -y update && \
 mkdir -p /usr/share/man/man1 && \
 apt-get -y install openjdk-12-jre-headless

我必须从 here to /etc/apt/sources.list file. This is for amd64 jre distribution so if you want a different one just check the bottom of this page and add mirror for the version you want, like I did in my Dockerfile. Additionaly I had to create folder /usr/share/man/man1 because of this bug 添加存储库。

最后我 运行 带有此图像的容器并检查了 java 版本 :

openjdk version "12.0.1" 2019-04-16
OpenJDK Runtime Environment (build 12.0.1+12-Debian-1)
OpenJDK 64-Bit Server VM (build 12.0.1+12-Debian-1, mixed mode, sharing)

希望这对您有所帮助:)