我想在docker image中的docker上安装openjdk。当我尝试这是获取此错误消息:
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community
ERROR: unsatisfiable constraints:
openjdk8-8.121.13-r0:
breaks: world[openjdk8=8.111.14-r0]
The command '/bin/sh -c set -x && apk add --no-cache openjdk8="$JAVA_ALPINE_VERSION" && [ "$JAVA_HOME" = "$(docker-java-home)" ]' returned a non-zero code: 1
我的Dockerfile目前看起来像这样:
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community
ERROR: unsatisfiable constraints:
openjdk8-8.121.13-r0:
breaks: world[openjdk8=8.111.14-r0]
The command '/bin/sh -c set -x && apk add --no-cache openjdk8="$JAVA_ALPINE_VERSION" && [ "$JAVA_HOME" = "$(docker-java-home)" ]' returned a non-zero code: 1
答案 0 :(得分:0)
有关于官方Java图像如何在高山图像上烘焙的Dockerfile参考: https://github.com/docker-library/openjdk/blob/9a0822673dffd3e5ba66f18a8547aa60faed6d08/8-jdk/alpine/Dockerfile
或者你可以用另一种方式来做,
# build ontop of official Java image
FROM java:openjdk-8-jdk-alpine
RUN apk update && \
apk add docker
...
答案 1 :(得分:0)
@ user2105103提到这是JDK版本的问题。
您只需跳过版本,问题就会消失。示例:
FROM docker:latest
# Default to UTF-8 file.encoding
ENV LANG C.UTF-8
# add a simple script that can auto-detect the appropriate JAVA_HOME value
# based on whether the JDK or only the JRE is installed
RUN { \
echo '#!/bin/sh'; \
echo 'set -e'; \
echo; \
echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
} > /usr/local/bin/docker-java-home \
&& chmod +x /usr/local/bin/docker-java-home
ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk
ENV PATH $PATH:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
ENV JAVA_VERSION 8u111
ENV JAVA_ALPINE_VERSION 8.111.14-r0
RUN set -x && apk add --no-cache openjdk8 && [ "$JAVA_HOME" = "$(docker-java-home)" ]
在这种情况下,您将获得最新的JDK版本。希望对您有所帮助。