如何在docker镜像openjdk:15中安装python。

3

我想创建一个包含OpenJDK 15和Python的镜像。

我正在尝试使用Dockerfile进行构建。

FROM    openjdk:15
RUN yum install -y oracle-epel-release-el7
RUN yum install -y python36

但是当我尝试构建该镜像时,它显示:

/bin/sh: yum: command not found
The command '/bin/sh -c yum install -y oracle-epel-release-el7' returned a non-zero code: 127

我也检查了这张图片

$ docker run --rm -it --entrypoint ""  openjdk:15 sh -c "cat /etc/os-release"
NAME="Oracle Linux Server"
VERSION="8.3"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="8.3"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Oracle Linux Server 8.3"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:8:3:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"

ORACLE_BUGZILLA_PRODUCT="Oracle Linux 8"
ORACLE_BUGZILLA_PRODUCT_VERSION=8.3
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=8.3

为什么这些需要是相同的镜像;你能从 python 构建第二个镜像吗? - David Maze
1
我需要将OpenJDK添加到t中。 - Santhosh
1个回答

7

看起来这个镜像上没有安装 yum。它使用 microdnf 作为包管理器。只需使用以下 Dockerfile 安装 Python 3.6:

FROM    openjdk:15
RUN microdnf install python36

在构建和运行带有 shell 进程的容器后,我收到了以下信息:

bash-4.4# python3 -V
Python 3.6.8

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接