Skip to content

Instantly share code, notes, and snippets.

@wxk6b1203
Created November 24, 2023 08:19
Show Gist options
  • Save wxk6b1203/266e60a86b68652d058513b676b35d14 to your computer and use it in GitHub Desktop.
Save wxk6b1203/266e60a86b68652d058513b676b35d14 to your computer and use it in GitHub Desktop.
Dockerfile of oracle JDK. A binary package named jdk-xxx.tar.gz should be placed in the same directory.
FROM ubuntu:latest
LABEL maintainer="wxk6b1203 <xxx>"
# Default to UTF-8 file.encoding
ENV LANG en_US.UTF-8
# Example oracle jdk version, change it to your own one.
ENV JAVA_HOME=/jdk1.8.0_371
ADD jdk-8u*.tar.gz /
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# RUN mv /jdk1.8* $JAVA_HOME
ENV PATH $JAVA_HOME/bin:$PATH
# change mirror to tuna
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
RUN apt-get update && apt-get install -y \
vim \
iputils-ping \
language-pack-zh-hans \
curl \
openssl \
&& rm -rf /var/lib/apt/lists/*
##
RUN ln -sfT "$JAVA_HOME" /usr/java/default; \
ln -sfT "$JAVA_HOME" /usr/java/latest; \
\
# -Xshare:dump will create a CDS archive to improve startup in subsequent runs
# the file will be stored as /usr/java/jdk-8/jre/lib/amd64/server/classes.jsa
# See https://docs.oracle.com/javase/8/docs/technotes/guides/vm/class-data-sharing.html
java -Xshare:dump;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment