python3 docker_构建Python3+Java8的 Docker 镜像

这篇博客介绍如何基于官方Python3镜像构建一个包含Java8环境的Docker镜像。Dockerfile中详细列出了安装步骤,包括设置环境变量、安装依赖、配置JAVA_HOME、下载并验证OpenJDK8、更新CA证书等。虽然在构建过程中遇到了网络问题和错误,但最终成功构建了镜像。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

基于官方Python3镜像来添加Java8环境(参考官方Dockerfile)

Dockerfile内容如下:

#

# NOTE: this docker file is used to build runtime environment.

# The project is a python app which contains a java jar lib.

FROM python:3

MAINTAINER yangpf

# COPY ./requirements.txt /usr/local/src/requirements.txt

RUN set -eux; \

apt-get update; \

apt-get install -y --no-install-recommends \

bzip2 \

unzip \

xz-utils \

\

# utilities for keeping Debian and OpenJDK CA certificates in sync

ca-certificates p11-kit \

# \

# java.lang.UnsatisfiedLinkError: /usr/local/openjdk-11/lib/libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory

# java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager

# https://github.com/docker-library/openjdk/pull/235#issuecomment-424466077

fontconfig libfreetype6 \

; \

rm -rf /var/lib/apt/lists/*

# Default to UTF-8 file.encoding

ENV LANG C.UTF-8

ENV JAVA_HOME /usr/local/openjdk-8

ENV PATH $JAVA_HOME/bin:$PATH

# backwards compatibility shim

RUN { echo '#/bin/sh'; echo 'echo "$JAVA_HOME"'; } > /usr/local/bin/docker-java-home && chmod +x /usr/local/bin/docker-java-home && [ "$JAVA_HOME" = "$(docker-java-home)" ]

# https://adoptopenjdk.net/upstream.html

# >

# > What are these binaries?

# >

# > These binaries are built by Red Hat on their infrastructure on behalf of the OpenJDK jdk8u and jdk11u projects. The binaries are created from the unmodified source code at OpenJDK. Although no formal support agreement is provided, please report any bugs you may find to https://bugs.java.com/.

# >

ENV JAVA_VERSION 8u252

ENV JAVA_BASE_URL https://github.com/AdoptOpenJDK/openjdk8-upstream-binaries/releases/download/jdk8u252-b09/OpenJDK8U-jre_

ENV JAVA_URL_VERSION 8u252b09

# https://github.com/dock

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值