dockerfile创建一个自己的jdk8镜像步骤
程序员文章站
2022-10-04 08:09:54
1、官方下载jdk8地址:https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html下载的版本:jdk-8u261-linux-x64.gz2、准备dockerfile# CentOS with JDK 8# Author hyf# build a new image with basic centosFROM centos# who is the authorMAINTAINER...
1、官方下载jdk8
地址:https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
下载的版本:jdk-8u261-linux-x64.gz
2、准备dockerfile
# CentOS with JDK 8
# Author hyf
# build a new image with basic centos
FROM centos
# who is the author
MAINTAINER hyf
# make a new directory to store the jdk files
RUN mkdir /usr/local/java
# copy the jdk archive to the image,and it will automaticlly unzip the tar file
ADD jdk-8u261-linux-x64.gz /usr/local/java/
# make a symbol link
RUN ln -s /usr/local/java/jdk1.8.0_261 /usr/local/java/jdk
# set environment variables
ENV JAVA_HOME /usr/local/java/jdk
ENV JRE_HOME ${JAVA_HOME}/jre
ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib
ENV PATH ${JAVA_HOME}/bin:$PATH
ENV LANG C.UTF-8
3、build 自己的docker镜像
docker build -t hyf/jdk8:centos .
镜像命名:hyf/jdk8:centos
路径:. 表示当前路径
如果有centos镜像生成会很快,如果没有,需要等待docker下载所需的镜像
4、查看生成镜像
docker images
可能需要的命令:
docker rm `docker ps -a | grep Exited | awk '{print $1}'` 删除异常停止的docker容器
docker rmi -f `docker images | grep '<none>' | awk '{print $3}'` 删除名称或标签为none的镜像
————————————————
版权声明:本文为CSDN博主「奔跑的阳光」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_36961530/java/article/details/79554964
5、测试使用
docker run -d -p 5580:5580 --cap-add=SYS_PTRACE -v /usr/share/zoneinfo/Asia/Shanghai:/etc/timezone -v /etc/localtime:/etc/localtime -v /home/schedule/Schedule.jar:/home/MyJarName.jar --name myAppName hyf/jdk8:centos java -jar -Xms300m -Xmx3g /home/MyJarName.jar
--cap-add=SYS_PTRACE
是为了使用jvm分析工具,jmap等
本文地址:https://blog.csdn.net/huyunfei/article/details/107361189
上一篇: 刚到一家装修公司上班