拉取
docker pull tomcat
[root@localhost test]# docker images tomcat
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat latest 238e6d7313e3 12 days ago 506MB
启动:
[root@localhost test]# docker run --name hbk_tomcat -p 8082:8080 -d tomcat
5e3eec4cc0a7746739e50dca547aa00af6d416593d16010446b7710917a80a44
查看进程
[root@localhost test]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5e3eec4cc0a7 tomcat "catalina.sh run" 28 seconds ago Up 25 seconds 0.0.0.0:8082->8080/tcp hbk_tomcat
9b021daa8309 nginx "nginx -g 'daemon ..." 2 hours ago Up 2 hours 0.0.0.0:9999->80/tcp php-nginx-hbk
f4cebdf34df1 php:5.6-fpm "docker-php-entryp..." 2 hours ago Up 2 hours 9000/tcp myphp-fpm
通过container id获取tomcat的启动日志
[root@localhost test]# docker logs 5e3eec4cc0a7
30-Jul-2019 09:29:36.547 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.43
30-Jul-2019 09:29:36.588 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jul 4 2019 20:53:15 UTC
30-Jul-2019 09:29:36.644 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.43.0
30-Jul-2019 09:29:36.646 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
30-Jul-2019 09:29:36.647 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 3.10.0-957.5.1.el7.x86_64
30-Jul-2019 09:29:36.662 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
30-Jul-2019 09:29:36.663 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/local/openjdk-8/jre
30-Jul-2019 09:29:36.665 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_222-b10
30-Jul-2019 09:29:36.673 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
30-Jul-2019 09:29:36.674 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/tomcat
30-Jul-2019 09:29:36.675 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/tomcat
30-Jul-2019 09:29:36.676 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
30-Jul-2019 09:29:36.677 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
30-Jul-2019 09:29:36.710 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
30-Jul-2019 09:29:36.711 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
30-Jul-2019 09:29:36.712 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
30-Jul-2019 09:29:36.713 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
30-Jul-2019 09:29:36.753 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
30-Jul-2019 09:29:36.755 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
30-Jul-2019 09:29:36.755 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
30-Jul-2019 09:29:36.770 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.23] using APR version [1.5.2].
30-Jul-2019 09:29:36.771 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
30-Jul-2019 09:29:36.772 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
30-Jul-2019 09:29:36.861 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.0k 28 May 2019]
30-Jul-2019 09:29:39.521 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
30-Jul-2019 09:29:39.745 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
30-Jul-2019 09:29:40.593 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
30-Jul-2019 09:29:40.688 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
30-Jul-2019 09:29:40.697 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 15108 ms
30-Jul-2019 09:29:41.352 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
30-Jul-2019 09:29:41.353 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.43
30-Jul-2019 09:29:41.680 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/ROOT]
30-Jul-2019 09:29:47.472 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/ROOT] has finished in [5,790] ms
30-Jul-2019 09:29:47.473 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/docs]
30-Jul-2019 09:29:47.723 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/docs] has finished in [241] ms
30-Jul-2019 09:29:47.723 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/examples]
30-Jul-2019 09:29:54.787 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/examples] has finished in [7,063] ms
30-Jul-2019 09:29:54.788 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/host-manager]
30-Jul-2019 09:29:55.608 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/host-manager] has finished in [807] ms
30-Jul-2019 09:29:55.610 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/manager]
30-Jul-2019 09:29:56.273 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/manager] has finished in [663] ms
30-Jul-2019 09:29:56.345 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
30-Jul-2019 09:29:56.996 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
30-Jul-2019 09:29:57.030 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 16332 ms
查看docker容器tomcat映射的本地端口
[root@localhost test]# docker port 5e3eec4cc0a7 8080
0.0.0.0:8082