Skip to content

Instantly share code, notes, and snippets.

@pushkarnk
Created October 6, 2023 15:00
Show Gist options
  • Save pushkarnk/a67875c30f45423b66a5313bfc1bf45d to your computer and use it in GitHub Desktop.
Save pushkarnk/a67875c30f45423b66a5313bfc1bf45d to your computer and use it in GitHub Desktop.
Copying jre-8 from a chiseled jre-8 image as a non-root user
FROM ubuntu/chiselled-jre:8-22.04_edge as chiselled-jdk8
FROM ubuntu:16.04
# Run as a non-root user
RUN addgroup --system test
RUN adduser --system testuser --ingroup test
USER testuser:test
COPY --from=chiselled-jdk8 /usr/lib/jvm/java-8-openjdk-amd64 /usr/lib/jvm/java-8-openjdk-amd64
COPY --from=chiselled-jdk8 /etc/java-8-openjdk/* /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/
# Needed on 16.04, 18.04, 20.04 - copying glibc binaries
COPY --from=chiselled-jdk8 /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu
COPY --from=chiselled-jdk8 /lib64 /lib64
# /usr/lib/jvm/java-8-openjdk-amd64/ now has a fully functional JDK
# There might be some symlinks to fixup
ENTRYPOINT ["/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment