dockerfilejlinkazul-zulu

/bin/sh: jlink: not found. command '/bin/sh -c jlink' returned a non-zero code: 127


the dockerfile used -

FROM azul/zulu-openjdk-alpine:11 as jdk

RUN jlink \
    --module-path /usr/lib/jvm/*/jmods/ \
    --verbose \
    --add-modules java.base,jdk.unsupported,java.sql,java.desktop \
    --compress 2 \
    --no-header-files \
    --no-man-pages \
    --output /opt/jdk-11-minimal

FROM alpine:3.10
ENV JAVA_HOME=/opt/jdk-11-minimal
ENV PATH=$PATH:/opt/jdk-11-minimal/bin
COPY --from=jdk /opt/jdk-11-minimal /opt/jdk-11-minimal

why jlink can't be found in azul/zulu-openjdk-alpine:11?


Solution

  • The simple answer is jlink is not on the PATH so can't be found.

    If you change the RUN line to

    RUN /usr/lib/jvm/zulu11/bin/jlink
    

    then it can be found.

    However, you still have an error using the wildcard in the module path. Change this to

    --module-path /usr/lib/jvm/zulu11/jmods/
    

    and the docker command will complete successfully.