title: How to add AdoptOpenJDK to Docker image?
body: <p>I've created a generic docker building file which includes utilities such as kubectl and Helm, but now I want to add adoptopenjdk to the image along with Maven, but when I test it Java crashes with a core dump.</p>
  
  <p>Here is the Dockerfile:</p>
  
  <pre><code># docker-build-test-image
  
  FROM    docker:stable-git
  
  ENV     KUBERNETES_VERSION 1.11.10
  ENV     HELM_VERSION 2.14.0
  ENV     JDK_FILE=OpenJDK11U-jdk_x64_linux_hotspot_11.0.4_11.tar.gz
  ENV     JDK_DIR=/opt/jdk-11.0.4+11
  ENV     LANG=C.UTF-8
  ENV     MAVEN_FILE apache-maven-3.3.9-bin.tar.gz
  
  RUN     apk update &amp;&amp; \
          apk add --no-cache curl &amp;&amp; \
          apk add --no-cache bash &amp;&amp; \
          apk add --no-cache jq &amp;&amp; \
          apk add --no-cache gettext &amp;&amp; \
          apk add --no-cache wget
  
  RUN     apk add -U openssl curl tar gzip bash ca-certificates git &amp;&amp; \
          curl -L -o /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub &amp;&amp; \
          curl -L -O https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk &amp;&amp; \
          apk add glibc-2.28-r0.apk &amp;&amp; \
          rm glibc-2.28-r0.apk
  
  RUN     curl "https://kubernetes-helm.storage.googleapis.com/helm-v${HELM_VERSION}-linux-amd64.tar.gz" | tar zx &amp;&amp; \
          mv linux-amd64/helm /usr/bin/ &amp;&amp; \
          mv linux-amd64/tiller /usr/bin/ &amp;&amp; \
          helm version --client &amp;&amp; \
          tiller -version
  
  RUN     curl -L -o /usr/bin/kubectl "https://storage.googleapis.com/kubernetes-release/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl" &amp;&amp; \
          chmod +x /usr/bin/kubectl &amp;&amp; \
          kubectl version --client
  
  # https://github.com/frol/docker-alpine-glibc/blob/master/Dockerfile
  # Here we install GNU libc (aka glibc) and set C.UTF-8 locale as default.
  
  RUN ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases/download" &amp;&amp; \
      ALPINE_GLIBC_PACKAGE_VERSION="2.28-r0" &amp;&amp; \
      ALPINE_GLIBC_BASE_PACKAGE_FILENAME="glibc-$ALPINE_GLIBC_PACKAGE_VERSION.apk" &amp;&amp; \
      ALPINE_GLIBC_BIN_PACKAGE_FILENAME="glibc-bin-$ALPINE_GLIBC_PACKAGE_VERSION.apk" &amp;&amp; \
      ALPINE_GLIBC_I18N_PACKAGE_FILENAME="glibc-i18n-$ALPINE_GLIBC_PACKAGE_VERSION.apk" &amp;&amp; \
      apk add --no-cache --virtual=.build-dependencies wget ca-certificates &amp;&amp; \
      echo \
          "-----BEGIN PUBLIC KEY-----\
          MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApZ2u1KJKUu/fW4A25y9m\
          y70AGEa/J3Wi5ibNVGNn1gT1r0VfgeWd0pUybS4UmcHdiNzxJPgoWQhV2SSW1JYu\
          tOqKZF5QSN6X937PTUpNBjUvLtTQ1ve1fp39uf/lEXPpFpOPL88LKnDBgbh7wkCp\
          m2KzLVGChf83MS0ShL6G9EQIAUxLm99VpgRjwqTQ/KfzGtpke1wqws4au0Ab4qPY\
          KXvMLSPLUp7cfulWvhmZSegr5AdhNw5KNizPqCJT8ZrGvgHypXyiFvvAH5YRtSsc\
          Zvo9GI2e2MaZyo9/lvb+LbLEJZKEQckqRj4P26gmASrZEPStwc+yqy1ShHLA0j6m\
          1QIDAQAB\
          -----END PUBLIC KEY-----" | sed 's/   */\n/g' &gt; "/etc/apk/keys/sgerrand.rsa.pub" &amp;&amp; \
      wget \
          "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
          "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
          "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" &amp;&amp; \
      apk add --no-cache \
          "$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
          "$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
          "$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" &amp;&amp; \
      \
      rm "/etc/apk/keys/sgerrand.rsa.pub" &amp;&amp; \
      /usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 "$LANG" || true &amp;&amp; \
      echo "export LANG=$LANG" &gt; /etc/profile.d/locale.sh &amp;&amp; \
      \
      apk del glibc-i18n &amp;&amp; \
      \
      rm "/root/.wget-hsts" &amp;&amp; \
      apk del .build-dependencies &amp;&amp; \
      rm \
          "$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
          "$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
          "$ALPINE_GLIBC_I18N_PACKAGE_FILENAME"
  
  WORKDIR /tmp
  RUN     chmod 755 /opt
  COPY    $JDK_FILE /tmp/
  RUN     tar -zvxf /tmp/$JDK_FILE -C /opt/ \
          &amp;&amp; rm /tmp/$JDK_FILE
  ENV     JAVA_HOME $JDK_DIR
  ENV     PATH "$PATH:$JDK_DIR/bin"
  
  RUN     wget --no-cookies --no-check-certificate "https://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/$MAVEN_FILE"
  RUN     pwd
  RUN     ls -ltr
  RUN     tar -zvxf $MAVEN_FILE  -C /opt/
  RUN     rm $MAVEN_FILE
  ENV     PATH "$PATH:/opt/apache-maven-3.3.9/bin"
  
  COPY    ./settings.xml /root/.m2/
  </code></pre>
  
  <p>The JDK_FILE "OpenJDK11U-jdk_x64_linux_hotspot_11.0.4_11.tar.gz" was downloaded directly from <a href="https://adoptopenjdk.net/releases.html?variant=openjdk11&amp;jvmVariant=hotspot" rel="nofollow noreferrer">https://adoptopenjdk.net/releases.html?variant=openjdk11&amp;jvmVariant=hotspot</a>.</p>
  
  <p>A really simple Java test file:</p>
  
  <pre><code>class HelloWorld 
  { 
      public static void main(String args[]) 
      { 
          System.out.println("Hello, World"); 
      } 
  }
  </code></pre>
  
  <p>And I'm building it via GitLab pipeline:</p>
  
  <pre><code>image: ${BUILD_URL}/tools/build/docker-build-test-image/add-jdk:20191129.33
  
  stages:
    - build
  
  build:
    stage: build
    script:
      - java -version
      - javac HelloWorld.java
      - java HelloWorld
  </code></pre>
  
  <p>And here is the output:</p>
  
  <pre><code>$ java -version
  openjdk version "11.0.4" 2019-07-16
  OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11)
  OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.4+11, mixed mode)
  #
  # A fatal error has been detected by the Java Runtime Environment:
  #
  #  [thread 20 also had an error]SIGSEGV
   (0xb) at pc=0x00007f0c0251bba1, pid=18, tid=28
  #
  # JRE version: OpenJDK Runtime Environment (11.0.4+11) (build 11.0.4+11)
  # Java VM: OpenJDK 64-Bit Server VM (11.0.4+11, mixed mode, tiered, compressed oops, serial gc, linux-amd64)
  # Problematic frame:
  # C  [libc.so.6+0x117ba1]
  #
  # Core dump will be written. Default location: Core dumps may be processed with "/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t e %P %I %h" (or dumping to /builds/d4e/playground/revills/java_test/core.18)
  #
  # An error report file with more information is saved as:
  # /builds/d4e/playground/revills/java_test/hs_err_pid18.log
  [thread 19 also had an error]
  #
  # If you would like to submit a bug report, please visit:
  #   https://github.com/AdoptOpenJDK/openjdk-build/issues
  #
  /bin/bash: line 111:    18 Aborted                 (core dumped) java -version
  </code></pre>
  
  <p>Could you please let me know what I have done wrong?</p>
  
  <p>Cheers,
  Steve</p>