docker安装tomcat

本文介绍了如何使用Docker来安装和运行Tomcat。首先,建议设置Docker加速器以提高下载速度,接着查看并拉取高评分的Tomcat镜像。然后创建容器,并检查正在运行的容器状态。通过进入容器,可以发现Tomcat的ROOT项目位于webapps.dist目录,需要将其复制到webapps目录才能在http://*****:8080/看到Tomcat的欢迎页面。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在拉取镜像之前最好设置加速器
docker加速器的设置请查看我的另外一篇文章链接: docker配置阿里云加速器.

查看镜像

docker search tomcat

选择stars数量最高的。
在这里插入图片描述

拉取镜像

docker pull tomcat

创建容器

通过守护进程方式后台运行tomcat
docker run -di --name tomcat -p 8080:8080 tomcat
使用进入tomcat容器
docker exec -it tomcat /bin/bash
或者
docker run -i -t --name tomcat_dev -p 8080:8080 tomcat /bin/bash
这种启动方式将会覆盖掉tomcat镜像Dockerfile文件中CMD默认执行的指令(默认执行脚本会启动tomcat),所以不会默认启动容器中的tomcat应用,需要手动启动。所以对于经常性运行的程序,比如apache,tomcat,Nginx建议使用守护式进程方式启动(-di)。
使用如下指令进入tomcat容器
docker attach tomcat
执行tomcat容器内的启动脚本启动tomcat,如果要访问主界面请往下看
sh /usr/local/tomcat/bin/startup.sh

查看当前的运行的容器

docker ps -a

进入容器

docker exec -it tomcat /bin/bash
或者
docker exec -it 容器id /bin/bash

查看 webapps 目录下是否有 ROOT 项目,我们熟悉的 Tomcat 猫页面一般就在这个项目中。

cd webapps
ls

在这里插入图片描述
如上图所示,该目录下空空如也,其实 Tomcat 在比较新的版本中将默认的 ROOT 项目放在了 webapps.dist 中,如果你真想访问 http://*****:8080/ 看到 Tomcat 猫,将其复制至 webapps 即可。

cd /usr/local/tomcat/webapps.dist
ls
cp -rf ROOT/ /usr/local/tomcat/webapps

在这里插入图片描述
通过 http://*****:8080/地址就可以访问tomcat的主界面了
在这里插入图片描述

You and your team have worked tirelessly until you have a sequence a1,a2,…,a2n+1 of positive integers satisfying these properties. 1≤ai≤1018 for all 1≤i≤2n+1 . a1,a2,…,a2n+1 are pairwise distinct. a1=a2−a3+a4−a5+…+a2n−a2n+1 . However, the people you worked with sabotaged you because they wanted to publish this sequence first. They deleted one number from this sequence and shuffled the rest, leaving you with a sequence b1,b2,…,b2n . You have forgotten the sequence a and want to find a way to recover it. If there are many possible sequences, you can output any of them. It can be proven under the constraints of the problem that at least one sequence a exists.    Input Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104 ). The description of the test cases follows. The first line of each test case contains one integer n (1≤n≤2⋅105 ). The second line of each test case contains 2n distinct integers b1,b2,…,b2n (1≤bi≤109 ), denoting the sequence b . It is guaranteed that the sum of n over all test cases does not exceed 2⋅105 .    Output For each test case, output 2n+1 distinct integers, denoting the sequence a (1≤ai≤1018 ). If there are multiple possible sequences, you can output any of them. The sequence a should satisfy the given conditions, and it should be possible to obtain b after deleting one element from a and shuffling the remaining elements. Example InputCopy 4 1 9 2 2 8 6 1 4 3 99 2 86 33 14 77 2 1 6 3 2 OutputCopy 7 9 2 1 8 4 6 9 86 99 2 77 69 14 33 4 6 1 2 3
最新发布
03-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值