4

I want to install the openjdk on the docker in docker image. When I try this is get this error message:

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 

My Dockerfile currently looks like this:

FROM docker:latest RUN apk update ENV LANG C.UTF-8 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_ALPINE_VERSION" \ && [ "$JAVA_HOME" = "$(docker-java-home)" ] 

2
  • 1
    Has zero to do with docker. This is an alpine contraint. Remove the version and it works fine.CommentedFeb 28, 2017 at 16:36
  • It also directly tells you what the problem is.CommentedFeb 28, 2017 at 16:48

2 Answers 2

2

There's a Dockerfile reference on how official Java image is baking on top of alpine image: https://github.com/docker-library/openjdk/blob/9a0822673dffd3e5ba66f18a8547aa60faed6d08/8-jdk/alpine/Dockerfile

Or you could do it another way around,

# build ontop of official Java image FROM java:openjdk-8-jdk-alpine RUN apk update && \ apk add docker ... 
2
  • If i need to use another base image?
    – Tomas F.
    CommentedMar 15, 2017 at 8:05
  • Then probably you would have to bake the image from your specific base image with java installation. But in most cases if the base image requires Java, they are most likely already baking their image that contain Java.
    – Leon
    CommentedMar 15, 2017 at 8:08
0

Well as @user2105103 mentioned this is a problem with JDK version.

You could simply skip the version and problem will disappear. Example:

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)" ] 

In this case you will get the latest JDK version. Hope it helps.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.