查看本地目录
[root@docker tomcat]# ls
apache-tomcat-8.5.16.tar.gz Dockerfile jdk-8u91-linux-x64.tar.gz server.xml
[root@docker tomcat]# vim Dockerfile
FROM centos:7
MAINTAINER zhaochengcheng
ADD jdk-8u91-linux-x64.tar.gz /usr/local
ENV JAVA_HOME /usr/local/jdk1.8.0_91
ADD apache-tomcat-8.5.16.tar.gz /usr/local
COPY server.xml /usr/local/apache-tomcat-8.5.16/conf
WORKDIR /usr/local/apache-tomcat-8.5.16
EXPOSE 8080
ENTRYPOINT ["./bin/catalina.sh", "run"]
构建镜像
[root@docker tomcat]# docker build -t tomcat:latest -f Dockerfile .
创建容器
[root@docker tomcat]# mkdir /app/webapps
[root@docker tomcat]# docker run -itd --name=tomcat -p 8080:8080 --mount type=bind,src=/app/webapps/,dst=/usr/local/apache-tomcat-8.5.16/webapps tomcat:latest
737494fcbca1aa73758666cbd8dc4dd8895028b2e869e56c97eb0ef9f10fdbf5
创建测试页
[root@docker tomcat]# ls /app/webapps/
[root@docker tomcat]# mkdir /app/webapps/ROOT
[root@docker tomcat]# vim /app/webapps/ROOT/index.html
[root@docker webapps]# cat ROOT/index.html
hello
测试war包
[root@docker webapps]# ls
jenkins jenkins.war ROOT