人生到头来,就是不断放下,但永远最令人心痛的就|

durtime

园龄:4年8个月粉丝:10关注:1

docker配置Nginx总结

1、首先拉取相关的镜像:

命令:docker pull nginx

 

 

 2、创建目录和文件,为容器挂载做准备

创建如下目录和文件夹

 

 

 在conf文件夹下,添加默认配置,也可自定义

命令:vim nginx.conf

nginx.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# user  nobody;
worker_processes  1;
 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
#pid        logs/nginx.pid;
 
 
events {
    worker_connections  1024;
}
 
 
http {
    include       mime.types;
    default_type  application/octet-stream;
 
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
 
    #access_log  logs/access.log  main;
 
    sendfile        on;
    #tcp_nopush     on;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
 
    gzip  on;
    # 包括当前目录下的conf.d文件夹的所有配置
    include ./conf.d/*.conf;
 
}

 在conf.d文件夹下,创建默认配置

命令:vim default.conf

default.conf

1
2
3
4
5
6
7
8
9
server {
    listen       80;
    server_name  localhost;
 
    location / {
        root html;
        index index.html;
    }
}

 3、创建运行容器

命令:docker run --name mynginx -p 80:80 -v /data/nginx/html:/usr/share/nginx/html -v /data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf  -v /data/nginx/logs:/var/log/nginx -v /data/nginx/conf.d:/etc/nginx/conf.d -d  nginx:latest

配置了nginx.conf,html页面logs的挂载

检测:挂载成功

 

 

本文作者:durtime

本文链接:https://www.cnblogs.com/durtime/p/15865938.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   durtime  阅读(123)  评论(0编辑  收藏  举报
历史上的今天:
2021-02-06 每日日报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
展开