docker部署网站

目录

拉取镜像

运行镜像

上传源码

访问网站


要求:基于容器的方式做一个apache编译安装的镜像,要求通过此镜像能够部署一个web站点,通过存储卷挂载到容器里面,最后成功访问

拉取镜像

在docker个人仓库中拉取之前上传的“在centos镜像上编译安装httpd”镜像

docker pull wqqw2419/httpd:v0.1
docker pull wqqw2419/httpd:v0.1
docker pull wqqw2419/httpd:v0.1

运行镜像

运行镜像并创建一个数据卷挂载到httpd的主页目录下

[root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE wqqw2419/httpd v0.1 5f8bd69fe43b 2 days ago 729MB centos latest 5d0da3dc9764 10 months ago 231MB [root@localhost ~]# docker run --name test -d -p 80:80 -v /test:/usr/local/apache/htdocs wqqw2419/httpd:v0.1 42175d5360708f9d31ad43e08119a2992ad259d4d1302d1293e613b44a5a9a69
[root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE wqqw2419/httpd v0.1 5f8bd69fe43b 2 days ago 729MB centos latest 5d0da3dc9764 10 months ago 231MB [root@localhost ~]# docker run --name test -d -p 80:80 -v /test:/usr/local/apache/htdocs wqqw2419/httpd:v0.1 42175d5360708f9d31ad43e08119a2992ad259d4d1302d1293e613b44a5a9a69 
[root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE wqqw2419/httpd v0.1 5f8bd69fe43b 2 days ago 729MB centos latest 5d0da3dc9764 10 months ago 231MB [root@localhost ~]# docker run --name test -d -p 80:80 -v /test:/usr/local/apache/htdocs wqqw2419/httpd:v0.1 42175d5360708f9d31ad43e08119a2992ad259d4d1302d1293e613b44a5a9a69

上传源码

将网站源码上传到本机的/test目录中并解压

[root@localhost ~]# cd /test/ [root@localhost test]# ls Battle_City audio css images index.html js ''$'\345\235\246\345\205\213''.zip'
[root@localhost ~]# cd /test/ [root@localhost test]# ls Battle_City audio css images index.html js ''$'\345\235\246\345\205\213''.zip' 
[root@localhost ~]# cd /test/ [root@localhost test]# ls Battle_City audio css images index.html js ''$'\345\235\246\345\205\213''.zip'

访问网站

使用本机ip+80端口访问

docker部署网站插图

原文链接:https://blog.csdn.net/Cinnamorollwq/article/details/126282879

© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享