[Docker] 8.1 Docker 部署 Tomcat

Docker 部署 Tomcat

Posted by Mr.Vincent on 2019-08-21
Estimated Reading Time 1 Minutes
Words 189 In Total
Viewed Times

搜索 tomcat 镜像

docker 官网:https://hub.docker.com/_/tomcat

1
docker search tomcat

下载 tomcat 镜像

默认最新版本

1
docker pull tomcat

运行 tomcat 容器

1
2
3
4
5
docker run \
--name tomcat \
-p 8080:8080 \
-v $PWD/ROOT:/usr/local/tomcat/webapps/ROOT \
-d tomcat

或者

1
2
3
4
5
docker run \
--name tomcat \
-p 8080:8080 \
-v /usr/local/docker/web/ROOT:/usr/local/tomcat/webapps/ROOT \
-d tomcat

命令说明:

  • -p 8080:8080:将容器的8080端口映射到主机的8080端口
  • -v $PWD/ROOT:/usr/local/tomcat/webapps/ROOT:将主机中当前目录下的 ROOT 挂载到容器的 /ROOT 或者 -v /usr/local/docker/web/ROOT:/usr/local/tomcat/webapps/ROOT:直接指定宿主机的绝对路径

查看容器启动情况

1
2
3
root@ubuntu:/usr/local/docker# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
65bed88bc006 tomcat "catalina.sh run" 41 seconds ago Up 40 seconds 0.0.0.0:8080->8080/tcp tomcat

If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you !