标签:usr using new tst 重启 code loaded lin form
tomcat部署web项目非常方便,把war包放到webapps目录就可以了。本篇使用docker快速搭建一个tomcat环境
拉取官方最新版tomcat镜像
[root@yoyo ~]# docker pull tomcat
Using default tag: latest
latest: Pulling from library/tomcat
6f2f362378c5: Pull complete
494c27a8a6b8: Pull complete
7596bb83081b: Pull complete
372744b62d49: Pull complete
fb72767f9beb: Pull complete
3fe571af508a: Pull complete
3e6725074325: Pull complete
9ffd5dadda90: Pull complete
4e051c2969b0: Pull complete
b326a8316680: Pull complete
Digest: sha256:cea26a23e1ebdbebdddde1e02a10e655b0b386d8de6002301a037a08be87a12f
Status: Downloaded newer image for tomcat:latest
查看已下载的镜像文件
[root@yoyo ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos v7.5 254d4dfe9df7 3 days ago 200MB
tomcat latest 5377fd8533c3 2 weeks ago 506MB
mysql 5.6 3ed1080b793f 2 weeks ago 256MB
mysql 5.7 a1aa4f76fab9 2 weeks ago 373MB
centos/python-36-centos7 latest b8d15efaa8ec 2 months ago 651MB
centos centos7.5.1804 cf49811e3cdb 3 months ago 200MB
ubuntu 15.10 9b9cb95443b5 2 years ago 137MB
training/webapp latest 6fae60ef3446 4 years ago 349MB
使用docker run 运行一个tomcat的容器
docker run --name yoyotomcat -p 8090:8080 -v ~/yoyo/tomcat/webapps/jenkins:/usr/local/tomcat/webapps/jenkins -d tomcat
运行成功后 docker ps查看已运行容器
[root@yoyo jenkins]# docker run --name yoyotomcat -p 8090:8080 -v ~/yoyo/tomcat/webapps/jenkins:/usr/local/tomcat/webapps/jenkins -d tomcat
[root@yoyo jenkins]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1d07763a6eaa tomcat "catalina.sh run" 15 minutes ago Up 7 minutes 0.0.0.0:8090->8080/tcp yoyotomcat
643c1f7c970c mysql:5.7 "docker-entrypoint.s…" 8 hours ago Up 27 minutes 33060/tcp, 0.0.0.0:3309->3306/tcp yoyomysql
37a3b50d151c mysql:5.6 "docker-entrypoint.s…" 25 hours ago Up 26 minutes 0.0.0.0:3308->3306/tcp mymysql
[root@yoyo jenkins]#
如果用的是阿里云服务器,需在后台开放8090端口,这样在浏览器输入http://主机ip:8090就能访问到tomcat首页了
tomcat环境已经部署完成,接下来把war包放到tomcat下的webapps目录就可以了,也就是/usr/local/tomcat/webapps。
前面启动的时候,/usr/local/tomcat/webapps/jenkins目录是挂载到本机的~/yoyo/tomcat//webapps/jenkins目录。
只需下载jenkins.war放到jenkins目录就可以了
[root@yoyo jenkins]# cd ~/yoyo/tomcat/webapps/jenkins/
[root@yoyo jenkins]# wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war
--2019-06-30 19:40:15-- http://mirrors.jenkins-ci.org/war/latest/jenkins.war
Resolving mirrors.jenkins-ci.org (mirrors.jenkins-ci.org)... 52.202.51.185
Connecting to mirrors.jenkins-ci.org (mirrors.jenkins-ci.org)|52.202.51.185|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://mirrors.tuna.tsinghua.edu.cn/jenkins/war/2.182/jenkins.war [following]
--2019-06-30 19:40:16-- http://mirrors.tuna.tsinghua.edu.cn/jenkins/war/2.182/jenkins.war
Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 77565765 (74M) [application/java-archive]
Saving to: ‘jenkins.war’
100%[=====================================================================================================================>] 77,565,765 12.1MB/s in 5.1s
2019-06-30 19:40:22 (14.4 MB/s) - ‘jenkins.war’ saved [77565765/77565765]
[root@yoyo jenkins]# jar -xvf jenkins.war
解压之后的目录
[root@yoyo jenkins]# ll
total 78212
drwxr-xr-x 3 root root 4096 Jun 23 20:22 bootstrap
-rw-r--r-- 1 root root 1946 Feb 7 12:49 ColorFormatter.class
drwxr-xr-x 5 root root 4096 Jun 23 20:22 css
-rw-r--r-- 1 root root 1544 Jun 23 20:18 dc-license.txt
drwxr-xr-x 2 root root 4096 Jun 23 20:22 executable
-rw-r--r-- 1 root root 17542 Jun 23 20:18 favicon.ico
drwxr-xr-x 12 root root 4096 Jun 23 20:22 help
drwxr-xr-x 6 root root 4096 Jun 23 20:22 images
-rw-r--r-- 1 root root 77565765 Jun 24 11:22 jenkins.war
-rw-r--r-- 1 root root 1674 Feb 7 12:49 JNLPMain.class
drwxr-xr-x 2 root root 4096 Jun 23 20:22 jsbundles
-rw-r--r-- 1 root root 862 Feb 7 12:49 LogFileOutputStream$1.class
-rw-r--r-- 1 root root 636 Feb 7 12:49 LogFileOutputStream$2.class
-rw-r--r-- 1 root root 2240 Feb 7 12:49 LogFileOutputStream.class
-rw-r--r-- 1 root root 20730 Feb 7 12:49 Main.class
-rw-r--r-- 1 root root 1048 Feb 7 12:49 MainDialog$1$1.class
-rw-r--r-- 1 root root 1067 Feb 7 12:49 MainDialog$1.class
-rw-r--r-- 1 root root 2633 Feb 7 12:49 MainDialog.class
-rw-r--r-- 1 root root 512 Feb 7 12:49 Main$FileAndDescription.class
drwxr-xr-x 3 root root 4096 Jun 30 19:22 META-INF
-rw-r--r-- 1 root root 71 Jun 23 20:18 robots.txt
drwxr-xr-x 3 root root 4096 Jun 23 20:22 scripts
drwxr-xr-x 7 root root 4096 Jun 23 20:22 WEB-INF
-rw-r--r-- 1 root root 2390099 May 12 15:50 winstone.jar
[root@yoyo jenkins]#
接着重启tomcat容器就可以生效了
docker restart yoyotomcat
浏览器输入访问地址:http://主机ip:8090/jenkins就能访问到主页面了
docker学习4-docker安装tomcat环境和部署war包
标签:usr using new tst 重启 code loaded lin form
原文地址:https://www.cnblogs.com/yoyoketang/p/11110795.html