1、拉取centos7镜像
docker pull centos:7
![](/i/l/?n=22&i=blog/741283/202210/741283-20221031165230374-1430653403.png)
vi Dockerfile FROM centos:7 MAINTAINER sheyu<[email protected]> ENV MYPATH /usr/local WORKDIR $MYPATH #安装vi编辑器 RUN yum -y install vi #安装ifconfig命令查看网络IP RUN yum -y install net-tools #安装java8及lib库 RUN yum -y install glibc.i686 RUN mkdir /usr/local/java #ADD 是相对路径jar,把jdk-8u171-linux-x64.tar.gz添加到容器中,安装包必须要和Dockerfile文件在同一位置 ADD jdk-8u171-linux-x64.tar.gz /usr/local/java/ #配置java环境变量 ENV JAVA_HOME /usr/local/java/jdk1.8.0_171 ENV JRE_HOME $JAVA_HOME/jre ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH ENV PATH $JAVA_HOME/bin:$PATH EXPOSE 80 CMD echo $MYPATH CMD echo "success--------------" CMD /bin/bash4、构建镜像
docker build -t centosjava8:v1.0 .
-------------------------
docker run -it 584044de82bc /bin/bash java -version ifconfig vi a.txt
标签:java,自定义,vi,centos7,ENV,HOME,镜像,JAVA From: https://www.cnblogs.com/zszitman/p/16844983.html