用Docker创建tomcat镜像的容器并部署实例并查看

创建好tomcat项目

下载tomcat镜像

sudo docker pull tomcat

创建tomacat容器

1 docker run并挂载数据卷

docker run -d -p 8083:8080 -v /yundata/docker-data/webapps/myapps/mytomcat/:/usr/local/tomcat/webapps/mytomcat/  tomcat

2 查看容器是否创建成功
用Docker创建tomcat镜像的容器并部署实例并查看_第1张图片

copy项目到tomcat容器中

sudo cp -Rf /media/ifeng/0000678400004823/apache-tomcat-7.0.67/webapps/mywork/WEB-INF/ /yundata/docker-data/webapps/myapps/mytomcat
sudo cp -Rf /media/ifeng/0000678400004823/apache-tomcat-7.0.67/webapps/mywork/index.jsp /yundata/docker-data/webapps/myapps/mytomcat

检验是否成功

http://localhost:8083/mytomcat/index.jsp

用Docker创建tomcat镜像的容器并部署实例并查看_第2张图片

也可以映射到8080端口

docker run -d -p 8080:8080 -v /mydocker/tomcat/docker-data/webapps/myapps/mytomcat/:/usr/local/tomcat/webapps/mytomcat/  666d


sudo cp -Rf /Users/ifeng/Desktop/web/WEB-INF/ /mydocker/tomcat/docker-data/webapps/myapps/mytomcat

sudo cp -Rf /Users/ifeng/Desktop/web/index.jsp /mydocker/tomcat/docker-data/webapps/myapps/mytomcat/


http://localhost:8080/mytomcat/index.jsp

你可能感兴趣的:(云计算,docker,tomcat,Docker,云计算入门)