docker 安装 tomcat8

Posted xiaojf

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker 安装 tomcat8相关的知识,希望对你有一定的参考价值。

docker hub 查找 tomcat

[email protected]:/etc/docker$ docker search tomcat
NAME                                       DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
tomcat                                     Apache Tomcat is an open source implementati…   2377                [OK]                
tomee                                      Apache TomEE is an all-Apache Java EE certif…   66                  [OK]                
dordoka/tomcat                             Ubuntu 14.04, Oracle JDK 8 and Tomcat 8 base…   53                                      [OK]
davidcaste/alpine-tomcat                   Apache Tomcat 7/8 using Oracle Java 7/8 with…   34                                      [OK]
bitnami/tomcat                             Bitnami Tomcat Docker Image                     28                                      [OK]
cloudesire/tomcat                          Tomcat server, 6/7/8                            14                                      [OK]
meirwa/spring-boot-tomcat-mysql-app        a sample spring-boot app using tomcat and My…   12                                      [OK]
aallam/tomcat-mysql                        Debian, Oracle JDK, Tomcat & MySQL              11                                      [OK]
tutum/tomcat                               Base docker image to run a Tomcat applicatio…   11                                      
jeanblanchard/tomcat                       Minimal Docker image with Apache Tomcat         8                                       
arm32v7/tomcat                             Apache Tomcat is an open source implementati…   6                                       
rightctrl/tomcat                           CentOS , Oracle Java, tomcat application ssl…   4                                       [OK]
maluuba/tomcat7-java8                      Tomcat7 with java8.                             3                                       
amd64/tomcat                               Apache Tomcat is an open source implementati…   2                                       
arm64v8/tomcat                             Apache Tomcat is an open source implementati…   2                                       
camptocamp/tomcat-logback                  Docker image for tomcat with logback integra…   1                                       [OK]
99taxis/tomcat7                            Tomcat7                                         1                                       [OK]
1and1internet/debian-9-java-8-tomcat-8.5   Our tomcat 8.5 image                            0                                       [OK]
s390x/tomcat                               Apache Tomcat is an open source implementati…   0                                       
swisstopo/service-print-tomcat             backend tomcat for service-print "the true, …   0                                       
picoded/tomcat7                            tomcat7 with jre8 and MANAGER_USER / MANAGER…   0                                       [OK]
oobsri/tomcat8                             Testing CI Jobs with different names.           0                                       
cfje/tomcat-resource                       Tomcat Concourse Resource                       0                                       
jelastic/tomcat                            An image of the Tomcat Java application serv…   0                                       
appsvc/tomcat                                                                              0                     

安装tomcat

[email protected]:/etc/docker$ docker pull tomcat:8.5.40

查看本地镜像,校验是否下载成功

mei[email protected]:/etc/docker$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              8.5.40              27600aa3d7f1        24 hours ago        463MB
tomcat              latest              27600aa3d7f1        24 hours ago        463MB

启动tomcat镜像,创建一个容器

[email protected]:/etc/docker$ docker run --name tomcat -d -p 8080:8080 tomcat:8.5.40

查看进程

[email protected]:/etc/docker$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                    NAMES
2ab1e4a82216        tomcat:8.5.40       "catalina.sh run"   10 hours ago        Up 10 hours         0.0.0.0:8080->8080/tcp   tomcat

查看日志

[email protected]:/etc/docker$ docker logs 2ab1e4a82216
09-May-2019 03:28:52.563 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.5.40
09-May-2019 03:28:52.564 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Apr 10 2019 14:31:19 UTC
09-May-2019 03:28:52.564 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.5.40.0
09-May-2019 03:28:52.565 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
09-May-2019 03:28:52.565 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            4.18.0-18-generic
09-May-2019 03:28:52.565 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
09-May-2019 03:28:52.565 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /usr/lib/jvm/java-8-openjdk-amd64/jre
09-May-2019 03:28:52.565 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_212-8u212-b01-1~deb9u1-b01
09-May-2019 03:28:52.565 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
09-May-2019 03:28:52.565 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/tomcat
09-May-2019 03:28:52.565 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/tomcat
09-May-2019 03:28:52.565 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
09-May-2019 03:28:52.565 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
09-May-2019 03:28:52.565 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
09-May-2019 03:28:52.565 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
09-May-2019 03:28:52.565 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
09-May-2019 03:28:52.565 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
09-May-2019 03:28:52.566 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
09-May-2019 03:28:52.566 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
09-May-2019 03:28:52.566 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
09-May-2019 03:28:52.566 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.21] using APR version [1.5.2].
09-May-2019 03:28:52.566 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
09-May-2019 03:28:52.566 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
09-May-2019 03:28:52.569 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.0j  20 Nov 2018]
09-May-2019 03:28:52.622 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
09-May-2019 03:28:52.629 INFO [main] org.apache.tomcat.util.net.NioselectorPool.getSharedSelector Using a shared selector for servlet write/read
09-May-2019 03:28:52.639 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
09-May-2019 03:28:52.640 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
09-May-2019 03:28:52.645 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 332 ms
09-May-2019 03:28:52.659 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
09-May-2019 03:28:52.660 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.40
09-May-2019 03:28:52.667 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/docs]
09-May-2019 03:28:52.826 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/docs] has finished in [159] ms
09-May-2019 03:28:52.827 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/examples]
09-May-2019 03:28:52.977 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/examples] has finished in [150] ms
09-May-2019 03:28:52.977 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/host-manager]
09-May-2019 03:28:53.001 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/host-manager] has finished in [24] ms
09-May-2019 03:28:53.001 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/ROOT]
09-May-2019 03:28:53.011 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/ROOT] has finished in [10] ms
09-May-2019 03:28:53.011 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/manager]
09-May-2019 03:28:53.023 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/manager] has finished in [12] ms
09-May-2019 03:28:53.025 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
09-May-2019 03:28:53.036 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
09-May-2019 03:28:53.037 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 392 ms

关掉tomcat进程

[email protected]:/etc/docker$ docker stop tomcat

启动tomcat进程

[email protected]:/etc/docker$ docker start tomcat

关掉tomcat进程

[email protected]:/etc/docker$ docker kill  tomcat
tomcat

删除tomcat容器

[email protected]:/etc/docker$ docker rm tomcat
tomcat

查看容器

[email protected]:/etc/docker$ docker ps 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

删除镜像

[email protected]:/etc/docker$ docker rmi tomcat
Untagged: tomcat:latest
[email protected]:/etc/docker$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              8.5.40              27600aa3d7f1        24 hours ago        463MB

 

以上是关于docker 安装 tomcat8的主要内容,如果未能解决你的问题,请参考以下文章

docker基于centos构建jdk8+tomcat8镜像

014-docker-centos-jdk8-nginx152-tomcat8

Vulhub Tomcat8 弱口令 && 后台getshell(底部有抽奖)

docker 常规软件的安装

Linux 部署Tomcat8

Linux 部署Tomcat8