标签:lib path usr inux mod html libc com 镜像
1.下载JDK/JRE压缩包。
jre-8u201-linux-x64.tar.gz
FROM docker.io/jeanblanchard/alpine-glibc
ADD ./package/jdk-8u201-linux-x64.tar.gz /usr/local/docker/java/jdk/
ENV JAVA_HOME=/usr/local/docker/java/jdk/jdk1.8.0_201
ENV CLASSPATH=$JAVA_HOME/bin
ENV PATH=.:$JAVA_HOME/bin:$PATH
CMD ["java","-version"]
# using apline-glibc instead of apline is mainly because JDK relies on glibc
FROM docker.io/jeanblanchard/alpine-glibc
# add jdk
ADD ./package/jre-8u201-linux-x64.tar.gz /usr/local/docker/java/jdk/
# env
ENV JAVA_HOME=/usr/local/docker/java/jdk/jre1.8.0_201
ENV CLASSPATH=$JAVA_HOME/bin
ENV PATH=.:$JAVA_HOME/bin:$PATH
# workdir
WORKDIR /opt
# cmd
CMD ["java","-version"]
.表示Dockerfile文件在当前目录。格式:docker build -t 镜像名称:tag 空格.
docker build -t java/jre1.8.0:201 .
docker build -t java.jdk1.8.0:201 .
REPOSITORY | TAG | IMAGE ID | CREATED | SIZE |
java/jdk1.8.0 | 201 | 8e99cccdb738 | About a minute ago | 408MB |
java/jre1.8.0 | 201 | 4b2b3e1e96e8 | 4 hours ago | 240MB |
# docker run -it java/jre1.8.0:201
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
# docker run -it java/jdk1.8.0:201
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
ctrl+p ctrl+q 退出当前容器。
标签:lib path usr inux mod html libc com 镜像
原文地址:https://www.cnblogs.com/lenovo_tiger_love/p/Docker.html