方法二、docker pull tomcat
查找Docker Hub上的tomcat镜像
[email protected]:~/tomcat$ docker search tomcat NAME DESCRIPTION STARS OFFICIAL AUTOMATED tomcat Apache Tomcat is an open source implementa... 744 [OK] dordoka/tomcat Ubuntu 14.04, Oracle JDK 8 and Tomcat 8 ba... 19 [OK] consol/tomcat-7.0 Tomcat 7.0.57, 8080, "admin/admin" 16 [OK] consol/tomcat-8.0 Tomcat 8.0.15, 8080, "admin/admin" 14 [OK] cloudesire/tomcat Tomcat server, 6/7/8 8 [OK] davidcaste/alpine-tomcat Apache Tomcat 7/8 using Oracle Java 7/8 wi... 6 [OK] andreptb/tomcat Debian Jessie based image with Apache Tomc... 4 [OK] kieker/tomcat 2 [OK] fbrx/tomcat Minimal Tomcat image based on Alpine Linux 2 [OK] jtech/tomcat Latest Tomcat production distribution on l... 1 [OK]
这里我们拉取官方的镜像
[email protected]:~/tomcat$ docker pull tomcat
等待下载完成后,我们就可以在本地镜像列表里查到REPOSITORY为tomcat的镜像。
使用tomcat镜像
运行容器
[email protected]:~/tomcat$ docker run --name tomcat -p 8080:8080 -v $PWD/test:/usr/local/tomcat/webapps/test -d tomcat acb33fcb4beb8d7f1ebace6f50f5fc204b1dbe9d524881267aa715c61cf75320 [email protected]:~/tomcat$
命令说明:
-p 8080:8080:将容器的8080端口映射到主机的8080端口
-v $PWD/test:/usr/local/tomcat/webapps/test:将主机中当前目录下的test挂载到容器的/test
查看容器启动情况
[email protected]:~/tomcat$ docker ps CONTAINER ID IMAGE COMMAND ... PORTS NAMES acb33fcb4beb tomcat "catalina.sh run" ... 0.0.0.0:8080->8080/tcp tomcat
通过浏览器访问
时间: 2024-11-05 19:34:57