Installing Java on docker in docker image

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

  • Execute chmod in Dockerfile on Raspberry pi /dev/spi*
  • How can I see a dynamically assigned port from within a docker container?
  • Dockerfile COPY / ADD fails for file in build context
  • Why is exposing known_hosts dangerous
  • How do I run Docker on Google Compute Engine?
  • Mount a volume while using a docker container in Azure App Service
  • fetch
    ERROR: unsatisfiable constraints:
        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
    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
    RUN set -x \
        && apk add --no-cache \
            openjdk8="$JAVA_ALPINE_VERSION" \
    && [ "$JAVA_HOME" = "$(docker-java-home)" ]

  • Unable to access Kubernetes UI
  • Increasing disk space for Agents/Worker nodes in Azure Container Service
  • Error while calling python subprocess in docker container
  • Gitlab pipeline fails during connect with EOF
  • Is it possible to set a different host port than the container's exposed port in docker?
  • Reflecting code changes in docker containers
  • One Solution collect form web for “Installing Java on docker in docker image”

    There’s a Dockerfile reference on how official Java image is baking on top of alpine image:

    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
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.