[docker] docker deployment tomcat

1.1 Search tomcat image
docker search tomcat
1.2 Pull tomcat image
docker pull tomcat
1.3 Create a container, set port mapping, directory mapping
# 在/root目录下创建tomcat目录用于存储tomcat数据信息
mkdir ~/tomcat
cd ~/tomcat
docker run -id --name=my_tomcat \
-p 8080:8080 \
-v $PWD:/usr/local/tomcat/webapps \
tomcat

Parameter Description:

-p 8080:8080:将容器的8080端口映射到主机的8080端口,第一个是主机的8080端口
-v $PWD:/usr/local/tomcat/webapps:将主机中当前目录挂载到容器的webapps
1.4 Testing

Create a test directory under the tomcat directory, create index.html, and edit the html content

mkdir test
vim index.html
<span>hello docker tomcat</span>

access

curl http://192.168.2.16:8080/test/index.html

or browser access
insert image description here

Guess you like

Origin blog.csdn.net/qq_32088869/article/details/131904943
Recommended