docker学习5-docker安装tomcat环境和部署war包

下载tomcat镜像

[root@bogon data]# docker pull tomcat
Using default tag: latest
latest: Pulling from library/tomcat
9cc2ad81d40d: Pulling fs layer
e6cb98e32a52: Pulling fs layer
ae1b8d879bad: Downloading
42cfa3699b05: Waiting
8d27062ef0ea: Waiting
9b91647396e3: Waiting
7498c1055ea3: Waiting
a183d8c2c929: Waiting
73dd800dda4c: Waiting
2bc71ef979ec: Waiting
latest: Pulling from library/tomcat
9cc2ad81d40d: Pull complete
e6cb98e32a52: Pull complete
ae1b8d879bad: Pull complete
42cfa3699b05: Pull complete
8d27062ef0ea: Pull complete
9b91647396e3: Pull complete
7498c1055ea3: Pull complete
a183d8c2c929: Pull complete
73dd800dda4c: Pull complete
2bc71ef979ec: Pull complete
Digest: sha256:80db17f3efd9cdcd9af7c799097fe0d223bbee8f25aa36234ab56292e3d8bd7b
Status: Downloaded newer image for tomcat:latest
docker.io/library/tomcat:latest
[root@bogon data]#

运行容器

使用docker run 运行一个tomcat的容器

  • --name yoyotomcat 容器重命名yoyotomcat
  • -p 8090:8080 容器的8080端口映射到主机的8090端口
  • -v ~/yoyo/tomcat/webapps/jenkins:/usr/local/tomcat/webapps/jenkins 容器的/usr/local/tomcat/webapps/jenkins 目录挂载到本机~/yoyo/tomcat/webapps/jenkins
  • -d 挂后台运行

[root@bogon webapps]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8f99aa298cc8 tomcat "catalina.sh run" 59 seconds ago Up 57 seconds 0.0.0.0:8089->8080/tcp leslietomcat
4252c716b85d mysql:5.7 "docker-entrypoint.s…" 2 hours ago Up 2 hours 33060/tcp, 0.0.0.0:3309->3306/tcp lesliemysql
[root@bogon webapps]#

这样在浏览器输入http://主机ip:8090就能访问到tomcat首页了

docker学习5-docker安装tomcat环境和部署war包

 

 

部署war包

因为自身有Jenkins,所以启动的时候映射到安装目录

[root@bogon /]# docker run --name leslietomcat -p 8089:8080 -v /opt/shaobo/apache-tomcat-9.0.20/webapps:/usr/local/tomcat/webapps -d tomcat

docker学习5-docker安装tomcat环境和部署war包

 

上一篇:1064 Complete Binary Search Tree (30 分)


下一篇:Springboot消除switch-case方法