构建Nginx Web应用

1.Dockerfile介绍

Dockfile是一种被Docker程序解释的脚本,Dockerfile由一条一条的指令组成。 Docker程序将读取Dockerfile,根据指令生成定制的image。

2.Nginx服务器介绍

Nginx是一款轻量级的Web服务器/反向代理服务器及电子邮(IMAP/POP3)代理服务器,并在一个BSD-like协议下发行。 特点是占有内存少,并发能力强,事实上Nginx的并发能力确实在同类型的网页服务器中表现较好。 中国使用Nginx网站用户有:百度、京东、新浪、网易、腾讯、淘宝等。

3.构建Nginx Web应用

(1)创建Dockerfile文件

# mkdir sample

# cd sample

# touch Dockerfile

(2)配置Nginx文件

# mkdir nginx && cd nginx

# wget https://raw.githubusercontent.com/jamtur01/dockerbook-code/master/code/5/sample/nginx/global.conf

# wget https://raw.githubusercontent.com/jamtur01/dockerbook-code/master/code/5/sample/nginx/nginx.conf

(3)为示例网站编写Dockerfile

# vi Dockerfile

(4)构建新的Nginx镜像

# docker build -t jamtur01/nginx .

(5)展示Nginx镜像的构建历史

# docker history jamtur01/nginx

(6)下载sample网站测试网页

[root@l-client sample]# mkdir website && cd website

[root@l-client website]# wget https://raw.githubusercontent.com/jamtur01/dockerbook-code/master/code/5/sample/website/index.html

(7)查看网站容器

# docker ps -l

(8)浏览sample网站

(9)修改网站实例网页

# vi /var/share/nginx/html/index.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值