zoukankan      html  css  js  c++  java
  • Docker笔记--官方的tomcat镜像使用

    公司准备将 j2ee的project上阿里云搬到 docker里,所以,先从一个tomcat的镜像开始吧!

    [root@muze1 ~]# docker pull tomcat
    Using default tag: latest
    latest: Pulling from library/tomcat
    Digest: sha256:71703331e3e7f8581f2a8206a612dbeedfbc7bb8caeee972eadca1cc4a72e6b1
    Status: Image is up to date for tomcat:latest
    docker.io/library/tomcat:latest

    查看本地已下载的镜像:

     基于这个image,创建一个容器 (run  创建容器并启动)

    [root@muze1 ~]# docker create --name my_tomcat -p 18080:8080 tomcat
    53884d3c6da92f097346a76cd4b848ec415bebe724514a27a53ef14799240789

    或者

    [root@muze1 ~]# docker run -itd --name my_tomcat -p 18080:8080 tomcat
    2cde258523aa2c093eeaef3836bde1fe108b3df231d281d90aa0986eaad3e5cf 

    image就相当于一个系统光盘,容器就是一台安装了这个系统电脑。启动:

     docker 容器日志查看:

    [root@muze1 ~]# docker logs my_tomcat
    NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
    03-Jun-2021 07:47:54.223 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.46
    03-Jun-2021 07:47:54.236 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: May 8 2021 17:35:52 UTC
    03-Jun-2021 07:47:54.236 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.46.0
    03-Jun-2021 07:47:54.236 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
    03-Jun-2021 07:47:54.236 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 3.10.0-1160.el7.x86_64
    03-Jun-2021 07:47:54.236 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
    03-Jun-2021 07:47:54.237 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/local/openjdk-11
    03-Jun-2021 07:47:54.237 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 11.0.11+9
    03-Jun-2021 07:47:54.237 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
    03-Jun-2021 07:47:54.237 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/tomcat
    03-Jun-2021 07:47:54.237 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/tomcat
    03-Jun-2021 07:47:54.295 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
    03-Jun-2021 07:47:54.295 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
    03-Jun-2021 07:47:54.296 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
    03-Jun-2021 07:47:54.296 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
    03-Jun-2021 07:47:54.296 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
    03-Jun-2021 07:47:54.296 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
    03-Jun-2021 07:47:54.296 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
    03-Jun-2021 07:47:54.296 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
    03-Jun-2021 07:47:54.296 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
    03-Jun-2021 07:47:54.297 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
    03-Jun-2021 07:47:54.314 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
    03-Jun-2021 07:47:54.315 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
    03-Jun-2021 07:47:54.315 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
    03-Jun-2021 07:47:54.315 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
    03-Jun-2021 07:47:54.345 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.28] using APR version [1.6.5].
    03-Jun-2021 07:47:54.345 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
    03-Jun-2021 07:47:54.346 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
    03-Jun-2021 07:47:54.359 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1d 10 Sep 2019]
    03-Jun-2021 07:47:55.250 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
    03-Jun-2021 07:47:55.329 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [1714] milliseconds
    03-Jun-2021 07:47:55.493 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
    03-Jun-2021 07:47:55.493 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.46]
    03-Jun-2021 07:47:55.523 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
    03-Jun-2021 07:47:55.587 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [257] milliseconds

     通过外端暴露的端口18080访问,404,什么鬼

     进入docker 容器查看tomcat进程:

    root@53884d3c6da9:/usr/local/tomcat# cd webapps
    root@53884d3c6da9:/usr/local/tomcat/webapps# ls
    root@53884d3c6da9:/usr/local/tomcat/webapps# cd ../webapps.dist/
    root@53884d3c6da9:/usr/local/tomcat/webapps.dist# ls
    ROOT docs examples host-manager manager

    解决办法

    1. 将 webapps 目录删掉,将 webapps.list 重命名为 webapps
    2. 进入 bin/ 目录,重新启动 tomcat
    3. root@53884d3c6da9:/usr/local/tomcat# rm -rf webapps
      root@53884d3c6da9:/usr/local/tomcat# mv webapps.dist webapps

    4. root@53884d3c6da9:/usr/local/tomcat# cd bin/
      root@53884d3c6da9:/usr/local/tomcat/bin# ls
      bootstrap.jar catalina.sh commons-daemon-native.tar.gz configtest.sh digest.sh setclasspath.sh startup.sh tool-wrapper.sh
      catalina-tasks.xml ciphers.sh commons-daemon.jar daemon.sh makebase.sh shutdown.sh tomcat-juli.jar version.sh
      root@53884d3c6da9:/usr/local/tomcat/bin# ./shutdown.sh
      Using CATALINA_BASE: /usr/local/tomcat
      Using CATALINA_HOME: /usr/local/tomcat
      Using CATALINA_TMPDIR: /usr/local/tomcat/temp
      Using JRE_HOME: /usr/local/openjdk-11
      Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
      Using CATALINA_OPTS:
      NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED

    5. root@53884d3c6da9:/usr/local/tomcat/bin# ./startup.sh
      Using CATALINA_BASE: /usr/local/tomcat
      Using CATALINA_HOME: /usr/local/tomcat
      Using CATALINA_TMPDIR: /usr/local/tomcat/temp
      Using JRE_HOME: /usr/local/openjdk-11
      Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
      Using CATALINA_OPTS:
      Tomcat started.
      root@53884d3c6da9:/usr/local/tomcat/bin# ps -ef|grep tomcat
      root 1 0 7 08:49 ? 00:00:03 /usr/local/openjdk-11/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
      root 70 37 0 08:50 pts/0 00:00:00 grep tomcat

  • 相关阅读:
    keil编译器从ac5迁移到ac6
    分享一个简单易用的软件定时器模块(MultiTimer)——基于keil+stm32f103zet+hal库(裸机实现)
    PID动图——很形象
    jlink之j-scope使用
    Keil的RTX特性
    Keil5创建基于RTX的STM32工程(转载+自己的体会)
    CMSIS-RTOS 简介
    Chapter 3 Phenomenon——13
    Chapter 3 Phenomenon——12
    Chapter 3 Phenomenon——11
  • 原文地址:https://www.cnblogs.com/vzhangxk/p/14845944.html
Copyright © 2011-2022 走看看