自定义Tomcat的基础镜像
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
本实验是在上一篇笔记中定义的JDK镜像的基础之上来自定义tomcat镜像的,请自行准备JDK环境,详情请参考:https://www.cnblogs.com/yinzhengjie/p/12220061.html.
一.下载Tomcat服务
1>.打开tomcat官网(http://tomcat.apache.org/)
2>.如下图所示,点击"Archies"(架构)
3>.选择一个相对较新的版本
4>.点击"bin",可以去下载tomcat对应的二进制安装包
5>.根据你的操作系统环境下载响应二进制安装包
6>.在服务器上使用wget工具下载tomcat安装包
[root@docker101.yinzhengjie.org.cn ~]# ll total 0 [root@docker101.yinzhengjie.org.cn ~]# [root@docker101.yinzhengjie.org.cn ~]# wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.50/bin/apache-tomcat-8.5.50.tar.gz --2020-01-22 12:19:01-- https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.50/bin/apache-tomcat-8.5.50.tar.gz Resolving archive.apache.org (archive.apache.org)... 163.172.17.199 Connecting to archive.apache.org (archive.apache.org)|163.172.17.199|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 10305939 (9.8M) [application/x-gzip] Saving to: ‘apache-tomcat-8.5.50.tar.gz’ 100%[==================================================================================================================================================>] 10,305,939 114KB/s in 84s 2020-01-22 12:20:27 (120 KB/s) - ‘apache-tomcat-8.5.50.tar.gz’ saved [10305939/10305939] [root@docker101.yinzhengjie.org.cn ~]# [root@docker101.yinzhengjie.org.cn ~]# ll total 10068 -rw-r--r-- 1 root root 10305939 Dec 8 03:42 apache-tomcat-8.5.50.tar.gz [root@docker101.yinzhengjie.org.cn ~]# [root@docker101.yinzhengjie.org.cn ~]# mv apache-tomcat-8.5.50.tar.gz /yinzhengjie/softwares/dockerfile/web/tomcat/tomcat-base/ [root@docker101.yinzhengjie.org.cn ~]# [root@docker101.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/dockerfile/web/tomcat/tomcat-base/ total 10068 -rw-r--r-- 1 root root 10305939 Dec 8 03:42 apache-tomcat-8.5.50.tar.gz [root@docker101.yinzhengjie.org.cn ~]# [root@docker101.yinzhengjie.org.cn ~]#
二.基于咱们自己的"jdk-base:1.8.0_231"镜像制作tomcat基础镜像
1>.编写Dockerfile
[root@docker101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/dockerfile/web/tomcat/tomcat-base/Dockerfile #******************************************************************** #Author: yinzhengjie #QQ: 1053419035 #Date: 2019-11-25 #Blog: http://www.cnblogs.com/yinzhengjie #Description: YinZhengjie's CentOS Base Dockerfile #Copyright notice: original works, no reprint! Otherwise, legal liability will be investigated. #******************************************************************** #基于咱们自己定义的JDK环境部署tomcat服务 FROM jdk-base:1.8.0_231 #指定镜像维护者的信息. MAINTAINER Jason.Yin y1053419035@qq.com #指定tomcat的解压目录 ADD apache-tomcat-8.5.50.tar.gz /yinzhengjie/softwares/web/ #创建软连接和专门存放tomcat代码目录 RUN ln -sv /yinzhengjie/softwares/web/apache-tomcat-8.5.50 /yinzhengjie/softwares/web/tomcat && mkdir -pv /yinzhengjie/data/tomcat/webapps [root@docker101.yinzhengjie.org.cn ~]#
2>.编译tomcat镜像
[root@docker101.yinzhengjie.org.cn ~]# [root@docker101.yinzhengjie.org.cn ~]# cd /yinzhengjie/softwares/dockerfile/web/tomcat/tomcat-base/ [root@docker101.yinzhengjie.org.cn /yinzhengjie/softwares/dockerfile/web/tomcat/tomcat-base]# [root@docker101.yinzhengjie.org.cn /yinzhengjie/softwares/dockerfile/web/tomcat/tomcat-base]# ll total 10076 -rw-r--r-- 1 root root 10305939 Dec 8 03:42 apache-tomcat-8.5.50.tar.gz -rw-r--r-- 1 root root 463 Jan 22 12:33 build-command.sh -rw-r--r-- 1 root root 796 Jan 22 12:30 Dockerfile [root@docker101.yinzhengjie.org.cn /yinzhengjie/softwares/dockerfile/web/tomcat/tomcat-base]# [root@docker101.yinzhengjie.org.cn /yinzhengjie/softwares/dockerfile/web/tomcat/tomcat-base]# cat build-command.sh #!/bin/bash # #******************************************************************** #Author: yinzhengjie #QQ: 1053419035 #Date: 2020-01-18 #FileName: docker-build.sh #URL: http://www.cnblogs.com/yinzhengjie #Description: Build jdk base Script #Copyright (C): 2020 All rights reserved #******************************************************************** docker image build -t tomcat-base:8.5.50 . [root@docker101.yinzhengjie.org.cn /yinzhengjie/softwares/dockerfile/web/tomcat/tomcat-base]# [root@docker101.yinzhengjie.org.cn /yinzhengjie/softwares/dockerfile/web/tomcat/tomcat-base]#
3>.编译tomcat镜像
三.验证咱们自定义的tomcat镜像
1>.运行容器启动tomcat服务
2>.浏览器访问tomcat