4-docker docker learning environment tomcat install and deploy war package

Foreword

tomcat web project deployment is very convenient, the war package into the webapps directory on it. Benpian use docker quickly build a tomcat environment

Download tomcat Mirror

Pull the latest official version of tomcat Mirror

[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

View the downloaded image file

[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

Run container

Use docker run run a tomcat container

  • --name yoyotomcat container heavy naming yoyotomcat
  • -p 8090: 8080 is mapped to the host port 8080 of container 8090 port
  • -v ~ / yoyo / tomcat / webapps / jenkins: / usr / local / tomcat / webapps / jenkins container / usr / local / tomcat / webapps / jenkins directory is mounted to the machine ~ / yoyo / tomcat / webapps / jenkins
  • -d hanging background

docker run --name yoyotomcat -p 8090:8080 -v ~/yoyo/tomcat/webapps/jenkins:/usr/local/tomcat/webapps/jenkins -d tomcat

After running a successful run container docker ps View

[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]# 

If you are using Ali cloud server, port 8090 to be open in the background, so your browser to http: // host ip: 8090 can access the home page to tomcat

Deploy war package

tomcat environment has been deployed, the next war package into the webapps directory of tomcat on it, that is, / usr / local / tomcat / webapps .
In front of the start time, / usr / local / tomcat / webapps / jenkins directory is mounted to the machine ~ / yoyo / tomcat // webapps / jenkins directory.
Just download jenkins.war put jenkins directory on it

  • cd to ~ / yoyo / tomcat / webapps / jenkins / directory
  • wget downloads jenkins.war
  • jar -xvf decompression jenkins.war
[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

Directory after decompression

[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]# 

Then restart tomcat container it would take

docker restart yoyotomcat

Access jenkins

Enter the access address browser: http: // host ip: 8090 / jenkins be able to access the main page

Guess you like

Origin www.cnblogs.com/yoyoketang/p/11110795.html