“Docker安装tomcat(本地版)”的版本间的差异
来自CloudWiki
第21行: | 第21行: | ||
f24d8b358bb1: Loading layer [=========================>] 2.56kB/2.56kB | f24d8b358bb1: Loading layer [=========================>] 2.56kB/2.56kB | ||
Loaded image: tomcat:latest | Loaded image: tomcat:latest | ||
+ | |||
+ | ==查询镜像== | ||
[root@controller ~]# docker images | [root@controller ~]# docker images | ||
− | + | REPOSITORY TAG IMAGE ID CREATED SIZE | |
− | latest | + | tomcat latest 3639174793ba 12 days ago 463MB |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
2019年5月28日 (二) 11:15的版本
上传tomcat包
通过CRT将tomcat包上传到centos系统中
加载已上传的tomcat包
[root@controller ~]# docker load -i tomcat.tar
f94641f1fe1f: Loading layer [=========================>] 105.5MB/105.5MB ec62f19bb3aa: Loading layer [=========================>] 24.08MB/24.08MB 2c719774c1e1: Loading layer [=========================>] 8.005MB/8.005MB 1b958b53b256: Loading layer [=========================>] 2.172MB/2.172MB 7d63f8777ebf: Loading layer [=========================>] 3.584kB/3.584kB fe60061c6c4e: Loading layer [=========================>] 1.536kB/1.536kB d38f3d5a39fb: Loading layer [=========================>] 317MB/317MB 2b6c38ff3137: Loading layer [=========================>] 2.56kB/2.56kB f0e1731fd286: Loading layer [=========================>] 1.894MB/1.894MB c8bcc49b9925: Loading layer [=========================>] 18.82MB/18.82MB f24d8b358bb1: Loading layer [=========================>] 2.56kB/2.56kB f24d8b358bb1: Loading layer [=========================>] 2.56kB/2.56kB Loaded image: tomcat:latest
查询镜像
[root@controller ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE tomcat latest 3639174793ba 12 days ago 463MB
等待下载完成后,我们就可以在本地镜像列表里查到REPOSITORY为tomcat的镜像。
[root@controller ~]# docker images|grep tomcat
tomcat latest 5a069ba3df4d Less than a second ago 465MB
使用用tomcat镜像
运行容器
runoob@runoob:~/tomcat$ docker run --name tomcat -p 8080:8080 -v $PWD/test:/usr/tomcat/webapps/test -d tomcat
acb33fcb4beb8d7f1ebace6f50f5fc204b1dbe9d524881267aa715c61cf75320
命令说明:
-p 8080:8080:将容器的8080端口映射到主机的8080端口
-v $PWD/test:/usr/local/tomcat/webapps/test:将主机中当前目录下的test挂载到容器的/test
查看容器启动情况
runoob@runoob:~/tomcat$ docker ps
CONTAINER ID IMAGE COMMAND ... PORTS NAMES acb33fcb4beb tomcat "catalina.sh run" ... 0.0.0.0:8080->8080/tcp tomcat
通过浏览器访问: http://10.0.0.20:8080/
(10.0.0.20为宿主机IP)
参考文档:http://www.runoob.com/docker/docker-install-tomcat.html