docker安装tomcat

1 . 环境:

  • cenos7(X86_64) + openssh

2 . 安装

  • 配置镜像加速器, 尝试从Docker Hub下载, 速度太慢

    /etc/docker/daemon.json

     {
        "max-concurrent-downloads":1,
        "registry-mirrors": [
           "https://hub-mirror.c.163.com",
           "https://mirror.baidubce.com"
        ]
     }
    
  • 抓取tomcat镜像
    docker pull tomcat
    
  • 启动容器
    docker run -d --name tongda-user -p 8082:8080 -v /root/log/user-log:/usr/local/tomcat/user-log tomcat
    
    
  • 验证容器
    http://xxx.xxx.xxx.xxx:8082
    HTTP状态 404 - 未找到
    类型 状态报告
    描述 源服务器未能找到目标资源的表示或者是不愿公开一个已经存在的资源表示。
    Apache Tomcat/9.0.41
    
  • 调整
    docker exec -it mytomcat /bin/bash
    mv webapps webapps2
    mv webapps.dist/ webapps
    exit
    

    验证成功

3 . 环境变量及配置文件:

Tomcat 镜像环境变量:

CATALINA_BASE:   /usr/local/tomcat
CATALINA_HOME:   /usr/local/tomcat
CATALINA_TMPDIR: /usr/local/tomcat/temp
JRE_HOME:        /usr
CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

配置文件默认位置:

/usr/local/tomcat/conf/

参考及引用

https://forums.docker.com/t/tomcat-give-error-404/95130
https://hub.docker.com/_/tomcat
Photo by Steve Johnson from Pexels

Comments are closed.