Docker安装TomCat

Docker安装TomCat

拉群镜像

#tomcat:n n为你想要下载的版本
docker pull tomcat:9.0

查看镜像

image-20210421105834715

启动镜像

# -d  以后台方式启动
# -p  将容器中的tomcat默认端口8080映射到本机的3355端口
# --name 给tomcat容器命名为 mytomcat
docker run -d -p 3355:8080 --name mytomcat tomcat9.0

测试访问

image-20210421111037670

测试访问没有,但是没有显示网页

进入容器内部

# exec 进入正在运行容器内部
# -it 交互式访问
docker exec -it mytomcat /bin/bash
root@b95178a5108a:/usr/local/tomcat# ls
BUILDING.txt     NOTICE         RUNNING.txt  lib             temp          work
CONTRIBUTING.md  README.md      bin          logs            webapps
LICENSE          RELEASE-NOTES  conf         native-jni-lib  webapps.dist
#进入webapps
root@b95178a5108a:/usr/local/tomcat# cd webapps
root@b95178a5108a:/usr/local/tomcat/webapps# ls -la
total 4
drwxr-xr-x  2 root root    6 Apr 11 03:31 .
drwxr-xr-x 11 root root 4096 Apr 11 03:31 ..

发现问题,1:linux命令少了,2、webapps东西不全,3:阿里云镜像的原因,默认是最小的镜像,所有不必要的的都剔除掉,保证最小的可运行环境

解决 我们发现Root目录在webapps.dist下面

#将webapps.dist中的所有文件复制到webapps中
cp -r webapps.dist/* webapps

image-20210421112258884

重新测试访问

image-20210421112422899

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值