• Docker容器部署Tomcat服务器


    1、拉取tomcat服务镜像文件

    root@ubuntu:~# docker pull registry.cn-hangzhou.aliyuncs.com/xxxx/xxxxx:web
    web: Pulling from registry.xxxxxxx/xiaoyaoji
    0586e6d4e45e: Extracting [==============>                                    ]  19.5 MB/67.1 MB
    0586e6d4e45e: Pulling fs layer 
    0586e6d4e45e: Downloading [==============================>                    ] 40.38 MB/67.1 MB
    15d45afac408: Download complete 
    9b8cebd39bac: Download complete 
    62ca1091452a: Download complete 
    07570fbab17a: Download complete 
    889ff497587a: Downloading [===========================>                       ] 103.3 MB/186.5 MB

    2、通过镜像生成容器

    root@ubuntu:~# docker run -d -p 80:8080 registry.cn-hangzhou.xxxxxx:web
    fdcbab15879c0e0f73377a37e7da1a9da4348e7a47308aab8fac2198c38fe2a8
    root@ubuntu:~# 
    root@ubuntu:~# 
    root@ubuntu:~# docker ps
    CONTAINER ID        IMAGE                                                   COMMAND                CREATED             STATUS              PORTS                            NAMES
    fdcbab15879c        registry.cn-hangzhou.aliyuncs.com/xxxxxx:web   "/bin/sh -c 'exec /u   4 seconds ago       Up 3 seconds        0.0.0.0:80->8080/tcp             berserk_kowalevski   
    d321e7650228        registry.cn-hangzhou.aliyuncs.xxxxxxxxx        "/usr/local/mysql/bi   47 minutes ago      Up 47 minutes       22/tcp, 0.0.0.0:4406->3306/tcp   admiring_franklin

    3、测试服务是否启动

    4、进入容器

    5、 编辑Tomcat容器内配置文件、修改端口信息等

    6、修改数据库配置文件信息。

    7、重启tomcat容器

    root@ubuntu:~# docker ps
    CONTAINER ID        IMAGE                                                   COMMAND                CREATED             STATUS              PORTS                            NAMES
    fdcbab15879c        registry.xxxxx:web        "/bin/sh -c 'exec /u   17 minutes ago      Up 17 minutes       0.0.0.0:80->8080/tcp             berserk_kowalevski   
    d321e7650228        registry.xxxxx:v2         "/usr/local/mysql/bi   About an hour ago   Up About an hour    22/tcp, 0.0.0.0:4406->3306/tcp   admiring_franklin    
    root@ubuntu:~# docker restart fdcbab15879c
    fdcbab15879c
    root@ubuntu:~# docker ps
    CONTAINER ID        IMAGE                                                   COMMAND                CREATED             STATUS              PORTS                            NAMES
    fdcbab15879c        registry.xxxx:web   "/bin/sh -c 'exec /u   17 minutes ago      Up 3 seconds        0.0.0.0:80->8080/tcp             berserk_kowalevski   
    d321e7650228        registry.xxxxx/mysql:v2        "/usr/local/mysql/bi   About an hour ago   Up About an hour

    重启项目:

    8、再次进入Tomcat容器,查看日志文件信息。

    root@ubuntu:~# docker restart fdcbab15879c
    fdcbab15879c
    root@ubuntu:~# docker ps
    CONTAINER ID        IMAGE                                                   COMMAND                CREATED             STATUS              PORTS                            NAMES
    fdcbab15879c        registry.xxxxxx/xiaoyaoji:web   "/bin/sh -c 'exec /u   17 minutes ago      Up 3 seconds        0.0.0.0:80->8080/tcp             berserk_kowalevski   
    d321e7650228        registry.xxxxxx/mysql:v2        "/usr/local/mysql/bi   About an hour ago   Up About an hour    22/tcp, 0.0.0.0:4406->3306/tcp   admiring_franklin    
    root@ubuntu:~# 
    root@ubuntu:~# 
    root@ubuntu:~# 
    root@ubuntu:~# docker exec -it fdcbab15879c bash
    root@fdcbab15879c:/# 
    root@fdcbab15879c:/# 
    root@fdcbab15879c:/# 
    root@fdcbab15879c:/# 
    root@fdcbab15879c:/# cd /usr/local/tomcat/apache-tomcat-7.0.78/logs/xyj 
    root@fdcbab15879c:/usr/local/tomcat/apache-tomcat-7.0.78/logs/xyj# ls
    error.log
    root@fdcbab15879c:/usr/local/tomcat/apache-tomcat-7.0.78/logs/xyj# tail -200f error.log 
        at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:142)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1410)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1464)
        at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:1969)
    2019-12-01 10:42:53,905 ERROR Druid-ConnectionPool-Create-28847804 com.alibaba.druid.pool.DruidDataSource - create connection error, url: jdbc:mysql://192.168.3.111:4406/api?useUnicode=true&characterEncoding=utf8, errorCode 1045, state 28000
    java.sql.SQLException: Access denied for user 'root'@'172.17.42.1' (using password: NO)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3887)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3823)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:870)
        at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1659)
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1206)
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2234)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2265)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2064)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:790)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
        at sun.reflect.GeneratedConstructorAccessor23.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:395)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
        at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:148)
        at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:211)
        at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:142)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1410)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1464)
        at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:1969)
    2019-12-01 10:43:07,749 ERROR http-bio-8080-exec-1 cn.com.xiaoyaoji.data.DataFactory - wait millis 10007, active 0, maxActive 100
    com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 10007, active 0, maxActive 100
        at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:1188)
        at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:1012)
        at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4544)
        at com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:662)
        at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4540)
        at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:990)
        at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:982)
        at cn.com.xiaoyaoji.util.JdbcUtils.getConnect(JdbcUtils.java:38)
        at cn.com.xiaoyaoji.data.DataFactory.process(DataFactory.java:65)
        at cn.com.xiaoyaoji.data.DataFactory.checkEmailExists(DataFactory.java:433)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at cn.com.xiaoyaoji.data.DataFactory$1.invoke(DataFactory.java:45)
        at com.sun.proxy.$Proxy31.checkEmailExists(Unknown Source)
        at cn.com.xiaoyaoji.service.ServiceFactory.checkEmailExists(ServiceFactory.java:155)
        at cn.com.xiaoyaoji.controller.UserController.create(UserController.java:68)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.valves.AccessLogValve.invo
  • 相关阅读:
    Matlab之快速傅里叶变换
    关于Debug和Release的区别 (VS C#)
    QSqlQuery::value: not positioned on a valid record
    UML系列图--用例图
    SQLite 数据类型总结
    c++构造函数
    求Fibonacci数列通项公式
    ObjectMapper类
    命令行运行jar 提示找不到主程序解决方案
    httpclient框架实现接口自动化的思路(二)
  • 原文地址:https://www.cnblogs.com/fighter007/p/11966560.html
Copyright © 2020-2023  润新知