docker中使用nginx镜像布置静态网站

版权声明:转载请著明出处 https://blog.csdn.net/weixin_40543283/article/details/88699934

本篇博客写的是使用docker镜像中的nginx来进行一个静态网站的部署

实验环境:

docker1:rhel7.3系统

镜像包:nginx.tar 在之前的文章里面分享过,可以翻着找一下

1.导入nginx镜像

[root@docker1 images]# docker load -i nginx.tar

2.运行nginx容器

[root@docker1 images]# docker run -it --name  vm1 nginx bash

3.容器内设置

root@e0d6fcaf179d:/# cd /usr/share/nginx/html
root@e0d6fcaf179d:/usr/share/nginx/html# echo www.orange_lei.com > index.html 
root@e0d6fcaf179d:/usr/share/nginx/html# cat index.html
www.orange_lei.com
root@e0d6fcaf179d:/usr/share/nginx/html# cd /usr/sbin/
root@e0d6fcaf179d:/usr/sbin# ./nginx

在容器内首先编辑网页html信息,然后启动nginx

4.查看nginx容器ip

按下ctrl+p然后按ctrl+q就可以将容器打入后台
[root@docker1 images]# docker inspect vm1            ##可以查看具体信息

5.测试

[root@docker1 images]# curl 172.17.0.2
www.orange_lei.com

这样一个静态网页就部署好了,容器是不是很方便呢,相比在虚拟机或者真机部署nginx~

猜你喜欢

转载自blog.csdn.net/weixin_40543283/article/details/88699934