编写DockerFile
新建一个文件,命名为:mytomcatdockerfile,没有后缀名,内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| FROM centos MAINTAINER LeDao<f1203007469@gmail.com> LABEL name="LeDao Tomcat Image" \ build-date="2021-08-22 00:16:53" COPY copyright.txt /home/copyright.txt ADD server-jre-8u151-linux-x64.tar.gz /home/ ADD apache-tomcat-8.5.37.tar.gz /home/ ENV WORKPATH /home/apache-tomcat-8.5.37/ WORKDIR $WORKPATH ENV JAVA_HOME /home/jdk1.8.0_151 ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar ENV CATALINA_HOME /home/apache-tomcat-8.5.37/ ENV CATALINA_BASE /home/apache-tomcat-8.5.37/ ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin EXPOSE 8080 CMD ["/home/apache-tomcat-8.5.37/bin/catalina.sh","run"]
|
复制文件
创建/home/dockerfile目录,把mytomcatdockerfile、copyright.txt、server-jre-8u151-linux-x64.tar.gz、apache-tomcat-8.5.37.tar.gz复制到该目录下,并进入该目录
四个文件的百度网盘链接:
链接:https://pan.baidu.com/s/1ldCQGNay95IvVlOzeMQdXg
提取码:62h2
创建镜像
命令的最后面有个英文句号.(少了句号不行)
1
| docker build -f mytomcatdockerfile -t a6678696/mytomcat:1.2 .
|
查看镜像构造历史