首页 > 其他分享 >群晖nas docker 挂载tomcat目录

群晖nas docker 挂载tomcat目录

时间:2023-07-20 22:00:11浏览次数:41  
标签:tomcat -- nas 群晖 挂载 docker 目录 tomcat8

前情

使用场景描述:

docker 安装了tomcat,想要通过tomcat部署war包,但是无法上次war包到容器,于是使用了挂载;

docker容器目录挂载 :

我们可以在创建容器的时候,将宿主机的目录与容器内的目录进行映射,这样我们就可以实现宿主机和容器目录的双向数据自动同步;

 

tomcat 安装和挂载目录

1.查找/下载tomcat 

docker pull billygoo/tomcat8-jdk8

2.启动tomcat

docker run -d -p 8080:8080 --name tomcat8 billygoo/tomcat8-jdk8:latest

 

3.复制tomcat8容器中tomcat目录 到nas 本地目录/docker/tomcat

docker cp tomcat8:/usr/local/tomcat /volume1/docker/tomcat

 

 

4.挂载目录

docker run --name tomcat -p 8088:8080 -v /volume1/docker/tomcat/tomcat:/usr/local/tomcat/  billygoo/tomcat8-jdk8:latest

5.更改tomcat用户(tomcat-users.xml),添加一个用户:

例如:

<user username="tomcat" password="tomcat" roles="manager-gui" />

完整文件如下:

 1 <?xml version='1.0' encoding='utf-8'?>
 2 <!--
 3   Licensed to the Apache Software Foundation (ASF) under one or more
 4   contributor license agreements.  See the NOTICE file distributed with
 5   this work for additional information regarding copyright ownership.
 6   The ASF licenses this file to You under the Apache License, Version 2.0
 7   (the "License"); you may not use this file except in compliance with
 8   the License.  You may obtain a copy of the License at
 9 
10       http://www.apache.org/licenses/LICENSE-2.0
11 
12   Unless required by applicable law or agreed to in writing, software
13   distributed under the License is distributed on an "AS IS" BASIS,
14   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   See the License for the specific language governing permissions and
16   limitations under the License.
17 -->
18 <tomcat-users xmlns="http://tomcat.apache.org/xml"
19               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20               xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
21               version="1.0">
22 <!--
23   NOTE:  By default, no user is included in the "manager-gui" role required
24   to operate the "/manager/html" web application.  If you wish to use this app,
25   you must define such a user - the username and password are arbitrary. It is
26   strongly recommended that you do NOT use one of the users in the commented out
27   section below since they are intended for use with the examples web
28   application.
29 -->
30 <user username="tomcat" password="tomcat" roles="manager-gui" />
31 <!--
32   NOTE:  The sample user and role entries below are intended for use with the
33   examples web application. They are wrapped in a comment and thus are ignored
34   when reading this file. If you wish to configure these users for use with the
35   examples web application, do not forget to remove the <!.. ..> that surrounds
36   them. You will also need to set the passwords to something appropriate.
37 -->
38 <!--
39   <role rolename="tomcat"/>
40   <role rolename="role1"/>
41   <user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
42   <user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
43   <user username="role1" password="<must-be-changed>" roles="role1"/>
44 -->
45 </tomcat-users>
View Code

 

6.修改server.xml配置:/docker/tomcat/tomcat/conf下的server.xml

找到<Host> 添加一条context   

<Context path="/muses" docBase="ssm-demo-mgt" reloadable="true" />
<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
          <Context path="/muses" docBase="ssm-demo-mgt" reloadable="true" />
        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>

 

7.上传war包到webapps目录下,并且重启tomcat  

重启指令:

docker restart tomcat

 

8.登入http://192.168.1.120:8088/manager/html 用户名密码就是刚刚设置的;tomcat  tomcat;

 9.访问war包:http://192.168.1.120:8088/muses/login

 

标签:tomcat,--,nas,群晖,挂载,docker,目录,tomcat8
From: https://www.cnblogs.com/lixiuming521125/p/17569804.html

相关文章

  • LeetCode 875. Koko Eating Bananas 二分答案
    Kokolovestoeatbananas.Thereare\(n\)pilesofbananas,the\(i\)thpilehas\(piles[i]\)bananas.Theguardshavegoneandwillcomebackinhhours.Kokocandecideherbananas-per-houreatingspeedofk.Eachhour,shechoosessomepileofb......
  • 黑群晖DSM7.2安装虚拟机生成序列号
    开启主板虚拟化!!!!存储空间系统格式btrfs 启用网卡OpenVSwitch设置  安装套件VirtualMachineManager      创建虚拟机    下一步直到完成,开启虚拟机  剩下就是链接助手链接虚拟机,配置一下就可以了全部完成后进入系统,打开控制面......
  • 黑群晖NAS7.0+安装问题解决经验分享
    感谢网上各种帖子及分享,为大家提供一个解决思路,机器配置多种多样,解决办法也仅供参考;1、引导后,无法找到群晖  遇到无法找到群晖的情况,首先要排除引导不兼容的问题。在bios中分别设置传统引导模式和UEFI引导模式尝试启动试下。最新版7.0.1的引导文件是两种启动方式都支持的,理......
  • Linux命令-按照与使用(17)(转载)解决同一台服务器上部署多个tomcat的同一个项目session冲
    ————————————————版权声明:本文为CSDN博主「strive_or_die」的原创文章,遵循CC4.0BY-SA版权协议,转载请附上原文出处链接及本声明。原文链接:https://blog.csdn.net/strive_or_die/article/details/103191546————————————————版权声明:本文为CS......
  • tomcat中conf目录中一些文件介绍
     tomcat中conf目录中一些文件说明server.xml文件:该文件用于配置和server相关的信息,比如tomcat启动的端口号、配置host主机、配置Contextweb.xml文件:部署描述文件,web.xml文件有两部分:Servlet类定义和Servlet映射定义。这个web.xml中描述了一些默认的servlet,部署每个webapp时......
  • tomcat中各目录文件用途
     查看tomcat目录   各目录文件用途 tomcat     |---bin:存放启动和关闭tomcat执行脚本;     |---conf:存放Tomcat服务器的各种全局配置文件,其中最重要的是server.xml和web.xml;     |---lib:存放Tomcat运行需要的库文件(jar),包含Tomcat使用的jar文件。unix平......
  • Tomcat中配置自定义404错误页面
    (1)%CATALINA_HOME%\conf\web.xml中web-app节点中添加<error-page><error-code>404</error-code><location>/404.html</location></error-page>在webapps下ROOT新增404.html页面<htmllang="en"><head&g......
  • 使用docker安装的tomcat部署activiti-app.war、activiti-admin.war失败(ClassNotFound
    背景一直以来习惯用docker配置一些本地学习环境,许多教程配置activiti的方式都是通过复制activiti的war包部署在tomcat中,我尝试了一下通过docker的方式遇到了一些不易察觉的错误。使用方式描述使用docker安装tomcat9.0dockerrun-d-p8080:8080--nametomcattomcat:9.0复......
  • Tomcat
    Tomcat3.1安装TomcatTomcat的默认端口号为:8080MySQL的默认端口号为:3306http的默认端口号为:80heeps的默认端口号为:4433.2Tomcat启动和配置3.3配置高难度面试题:请你谈谈网站是如何进行访问的?输入一个域名,回车;检查本机的C:\Windows\System32\drivers\hosts......
  • tomcat 8.5 的安装配置
    下载软件包链接:https://pan.baidu.com/s/1VP9MGxjpWm3gawhxjIvYrg提取码:xooe--来自百度网盘超级会员V6的分享1、注意解压还要拿到最里面的文件夹,存放的软件目录不能是中文的 同样的将上面文件路径复制粘贴到记事本,等下要用CATALINA_HOMED:\mysoft\apache-tomcat-8.5.15......