【Vegas原创】docker安装TOMCAT,并运行本地代码

2年前 (2022) 程序员胖胖胖虎阿
203 0 0

1,docker 下载tomcat

[root@it-1c2d ~]# docker pull tomcat
 ...
[root@it-1c2d ~]# docker images
REPOSITORY                                                                    TAG        IMAGE ID       CREATED         SIZE
tomcat                                                                        latest     6313f84af805   4 days ago      680MB

2,docker安装

[root@it-1c2d webnav]# docker run --name tomcat -p 8081:8080 -v /ZT/webnav/:/usr/local/tomcat/webapps -d tomcat 
311dcda238320954eaf01d109d017c3dd675ece66c41a05b365599ac85346a71
[root@it-1c2d webnav]# docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS                                                                      NAMES
311dcda23832   tomcat         "catalina.sh run"        15 seconds ago   Up 14 seconds   0.0.0.0:8081->8080/tcp, :::8081->8080/tcp                                  tomcat
e6b306df750b   nginx          "/docker-entrypoint.…"   6 weeks ago      Up 6 weeks      0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   nginx
04b2dde69bbe   wiki0829       "docker-entrypoint.s…"   6 weeks ago      Up 6 weeks      3443/tcp, 0.0.0.0:8080->3000/tcp, :::8080->3000/tcp                        wiki
fdfc369cacfa   mysql:latest   "docker-entrypoint.s…"   5 months ago     Up 6 weeks      0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp

其中:用 -v 指令指定把容器中的某个文件夹挂载到宿主机中
它的语法为:  -v 宿主机目录:容器目录

-d: 后台运行容器,并返回容器ID

相关文章

暂无评论

暂无评论...