Alpine Linux - 未找到 javac

2022-09-02 12:40:40

我正在尝试构建一个包含OpenJDK的Alpine Linux映像。安装了 Java 运行时 (),但安装了 Java 编译器 ()。我希望编译器附带OpenJDK,就像通过或安装时一样。javajavacaptyum

FROM alpine:latest

RUN apk update
RUN apk add bash openjdk8

RUN java -version
RUN javac --version

构建 Dockerfile 时,将返回以下错误:The command '/bin/sh -c javac -version' returned a non-zero code: 127

如何在Alpine上使用Java编译器?


答案 1

试试这个:

FROM alpine:latest
USER root

RUN apk update
RUN apk fetch openjdk8
RUN apk add openjdk8
ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk
ENV PATH="$JAVA_HOME/bin:${PATH}"

RUN java -version
RUN javac -version

答案 2

推荐