aiVMS------Docker 安装Nginx1.16.0(五)

Docker安装Nginx

一、通过docker pull nginx安装

1.查找docker上的镜像

[root@shijie ~]# docker search -s 100 nginx

2. docker中下载Nginx(1.16.0稳定版本)

[root@shijie ~]# docker pull nginx:1.16.0

aiVMS------Docker 安装Nginx1.16.0(五)_第1张图片

3.启动部署容器并映射

  1. 创建目录nginx,用于存放相关参数
    [root@shijie nginx]# mkdir -p /usr/local/docker/nginx/html /usr/local/docker/nginx/conf /usr/local/docker/nginx/conf.d /usr/local/docker/nginx/logs

     

  2. 拷贝容器内nginx默认配置文件到本地目录下,容器ID查看docker ps
    [root@shijie nginx]# docker cp ca430d2e5b81:/etc/nginx/nginx.conf /usr/local/docker/nginx/conf/
    [root@shijie nginx]# docker cp ca430d2e5b81:/etc/nginx/conf.d/default.conf /usr/local/docker/nginx/conf.d/
    

     

  3.  
[root@shijie ~]# docker run -p 80:80 -d --name mynginx --restart=always -v /usr/local/docker/nginx/html:/usr/share/nginx/html -v /usr/local/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro -v /usr/local/docker/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf:ro -v /usr/local/docker/nginx/logs:/var/log/nginx nginx:1.16.0


docker run -p 80:80 -d --name mynginx --restart=always -v /usr/local/docker/nginx/html:/usr/share/nginx/html -v /usr/local/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro -v /usr/local/docker/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf:ro -v /usr/local/docker/nginx/logs:/var/log/nginx nginx:1.16.0

-p:端口进行映射

-d 容器在后台一直运行

mynginx 容器名称

-v 挂载


 

4.通过浏览器输入主机IP地址查看

aiVMS------Docker 安装Nginx1.16.0(五)_第2张图片

5.后期调试在/usr/local/docker/nginx目录下调试即可!

 

 

 

 

 

 

 

你可能感兴趣的:(Nginx)