构建业务镜像2
准备自定义页面和其它数据
[root@ubuntu1804 tomcat]#pwd
/data/dockerfile/web/tomcat
[root@ubuntu1804 tomcat]#cp -a tomcat-app1/* tomcat-app2/
[root@ubuntu1804 tomcat]#tree tomcat-app2/
tomcat-app2/
├── app
│ └── index.jsp
├── app.tar.gz
├── build.sh
├── Dockerfile
├── run_tomcat.sh
└── server.xml
1 directory, 6 files
[root@ubuntu1804 tomcat]#cd tomcat-app2
[root@ubuntu1804 tomcat-app2]#echo "Tomcat Page in app2" > app/index.html
[root@ubuntu1804 tomcat-app2]#rm -f app.tar.gz
[root@ubuntu1804 tomcat-app2]#tar zcf app.tar.gz app
准备容器启动脚本run_tomcat.sh
和业务1一样不变
准备Dockerfile
和业务1一样不变
执行构建脚本制作镜像
[root@ubuntu1804 tomcat-app2]#vim build.sh
[root@ubuntu1804 tomcat-app2]#cat build.sh
#!/bin/bash
docker build -t tomcat-web:app2 .
[root@ubuntu1804 tomcat-app2]#bash build.sh
[root@ubuntu1804 tomcat-app2]#docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat-web app2 0e1760fe79a6 37 seconds ago 838MB
tomcat-web app1 76016219a0ca 27 minutes ago 838MB
tomcat-base v8.5.50 8d5395cb72c4 2 hours ago 824MB
centos7-jdk 8u212 e0fe770a7ccd 2 hours ago 809MB
centos7-base v1 34ab3afcd3b3 3 hours ago 403MB
centos centos7.7.1908 08d05d1d5859 2 months ago 204MB
从镜像启动容器测试
[root@ubuntu1804 tomcat-app2]#docker run -d -p 8082:8080 tomcat-web:app2
3fc9437e42099e92f88e8e09bac0507f2d837ac8a6dba8cb1e4efc934bcf81ff
访问测试
[root@ubuntu1804 tomcat-app2]#curl 127.0.0.1:8082/app/
Tomcat Page in app2
本文链接:http://www.yunweipai.com/34846.html
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/52668.html