docker 离线部署 tomcat

docker 离线部署 tomcat

docker hub在线地址:tomcat 镜像地址
目录架构
docker 离线部署 tomcat_第1张图片

1、离线安装docker 和 docker-compose

具体请参考一下链接进行安装

docker && docker-compose离线部署

2、下载tomcat镜像 (有网环境)

  • 先在有网络的环境下拉取tomcat镜像
docker pull tomcat:9.0.73

3、打包镜像文件到本地

# 参数说明 -o :输出到的文件
docker save tomcat:9.0.73 -o tomcat.tar
  • 将tomcat.tar 下载到自己本地电脑,在将tomcat.tar上传到要部署的内网服务器上

4、将镜像文件导入到内网环境的服务器上(无网内网环境)

# 创建目录
mkdir -p /usr/local/tomcat&& cd /usr/local/tomcat
# 导入镜像 参数说明 --input , -i : 指定导入的文件
docker load -i tomcat.tar

5、编写docker-compose.yml文件

vim docker-compose.yml
version: "3"
services:

  tomcat:
      image: "tomcat:9.0.73"
      container_name: tomcat
      restart: always
      ports:
        - 8080:8080
      volumes:
        # 中间件日志挂载目录
        - ./logs:/usr/local/tomcat/logs
        # 发布war包时把注释删掉并在tomcat跟目录下创建webapps目录用于上传war包
        - ./webapps:/usr/local/tomcat/webapps/ 
         # 配置
        - ./conf/server.xml:/usr/local/tomcat/conf/server.xml
# 可以修改端口,默认端口8080
vim server.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

  
  
  
  
  

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  
    
    
  

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
    -->
    
    
    
    
    
    
    

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    

      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      
        
        
      

      >

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        

      >
    >
  >
>

6、启动tomcat

# 启动
docker-compose up -d
# 关闭
docker-compose down

docker 离线部署 tomcat_第2张图片

7、关闭防火墙

# centos 麒麟
firewall-cmd --zone=public --add-port=8080/tcp --permanent  && firewall-cmd --reload
# ubantu
sudo ufw allow 8080

在这里插入图片描述

8、将geoserver.war 上传到/usr/local/tomcat/webapps下

在这里插入图片描述

9、浏览器访问 tomcat

# IP填写自己的地址 
http://192.168.127.140:8080/geoserver

docker 离线部署 tomcat_第3张图片

你可能感兴趣的:(docker,docker,linux,tomcat)