27

My Dockerfile:

FROM frolvlad/alpine-glibc:latest

ADD jdk-11.0.6_linux-x64_bin.tar.gz /usr/java

ENV JAVA_HOME=/usr/java/jdk-11.0.6
ENV PATH=$JAVA_HOME/bin:$PATH

When I run the command java -version in the container, I get this segfault: enter image description here

How can I solve this problem?

Matthieu
  • 2,736
  • 4
  • 57
  • 87
DWG24
  • 271
  • 1
  • 3
  • 3

2 Answers2

43

frolvlad/alpine-glibc is a glibc-enabled Alpine Linux image, and jdk-11.0.6_linux-x64_bin.tar.gz is likely a mainland Linux JDK glibc build. In theory, this should be fine, but there may be subtle glibc incompatibilities that cause this.

If you're looking for Java 11 on Alpine, you could just grab the vanilla Alpine 3.11 image, then install the openjdk11 package on top:

sudo docker run -it alpine:3.11

# apk add openjdk11

# java -version
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-alpine-r0)
OpenJDK 64-Bit Server VM (build 11.0.5+10-alpine-r0, mixed mode)

If you need 11.0.6 specifically, install the latest openjdk11 package of the edge/community repository instead:

apk add openjdk11 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community

valiano
  • 16,433
  • 7
  • 64
  • 79
  • 2
    Thank you for your suggestions, but for some reason, my program uses Oracle jdk11, not openjdk11, and I have not carefully tested my program on openjdk11. – DWG24 Feb 02 '20 at 06:14
  • Hi @Brucewayne-TheGeekKiller, could you update on what isn't working? I'll try to update the answer with relevant information. – valiano Feb 17 '21 at 14:56
  • 2
    Thank you! Any available package can be found here https://pkgs.alpinelinux.org/packages?name=openjdk11&branch=v3.11 It is also suggested to update package list first, i.e. `apk --update-cache add openjdk11` https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Update_the_Package_list – igor Aug 15 '21 at 15:30
  • Do we need to login into http://dl-cdn.alpinelinux.org/alpine repo? – Kanagavelu Sugumar Aug 08 '23 at 13:46
12

From a working container

FROM alpine:3.14

RUN  apk update \
  && apk upgrade \
  && apk add ca-certificates \
  && update-ca-certificates \
  && apk add --update coreutils && rm -rf /var/cache/apk/*   \ 
  && apk add --update openjdk11 tzdata curl unzip bash \
  && apk add --no-cache nss \
  && rm -rf /var/cache/apk/*