How to manage nginx based on docker,part I

  今天我们来简要演示一下,如何基于docker部署nginx。

run nginx:


[root@node01 ~]# docker run -d -p 80:80 -p 443:443 -v /nginx/nginx.conf:/etc/nginx/nginx.conf:ro -v /nginx/default.conf:/etc/nginx/conf.d/default.conf -v /html/:/html/ -v /cert:/cert nginx:latest
[root@node01 ~]# docker ps 
CONTAINER ID        IMAGE                                COMMAND                  CREATED             STATUS              PORTS                                      NAMES
01eb112d6fb4        nginx:latest                         "nginx -g 'daemon of…"   16 minutes ago      Up 16 minutes       0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   dazzling_mahavira
ed2ff70e1376        47.x.y.192:5000/center:19.7.8.3   "java -Djava.securit…"   4 weeks ago         Up 11 minutes       0.0.0.0:8083->8083/tcp, 8092/tcp           awesome_mestorf
c041ddabdd2e        registry:2                           "/entrypoint.sh /etc…"   5 months ago        Up 2 months         0.0.0.0:5000->5000/tcp                     registry2
[root@node01 ~]# 

  可以看到nginx已经启动成功。

view logger for nginx

  可以用如下命令查看nginx日志。

[root@node01 ~]# docker logs -f 01eb112d6fb4
2019/08/06 02:25:47 [warn] 1#1: the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/conf.d/default.conf:5
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/conf.d/default.conf:5
2019/08/06 02:25:47 [warn] 1#1: the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/conf.d/default.conf:37
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/conf.d/default.conf:37

restart nginx

  可以用如下命令重启nginx。

[root@node01 ~]# docker ps 
CONTAINER ID        IMAGE                                COMMAND                  CREATED             STATUS              PORTS                                      NAMES
01eb112d6fb4        nginx:latest                         "nginx -g 'daemon of…"   26 minutes ago      Up 26 minutes       0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   dazzling_mahavira
ed2ff70e1376        47.x.y.192:5000/center:19.7.8.3   "java -Djava.securit…"   4 weeks ago         Up 21 minutes       0.0.0.0:8083->8083/tcp, 8092/tcp           awesome_mestorf
c041ddabdd2e        registry:2                           "/entrypoint.sh /etc…"   5 months ago        Up 2 months         0.0.0.0:5000->5000/tcp                     registry2
[root@node01 ~]# docker restart 01eb112d6fb4
01eb112d6fb4
[root@node01 ~]# 

stop nginx

  可以用如下命令关闭nginx。

[root@node01 ~]# docker stop 01eb112d6fb4
01eb112d6fb4
[root@node01 ~]#

start nginx

  可以用如下命令启动nginx。

[root@node01 ~]# docker start 01eb112d6fb4
01eb112d6fb4
[root@node01 ~]#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qwfys200

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值