docker + nginx起一个简单的图片服务器

  • 拉取官方nginx镜像
  • 新建一个nginx.conf文件,编辑以下内容
    server {
        listen       80;
        server_name  localhost;
    
        #charset koi8-r;
        #access_log  /var/log/nginx/host.access.log  main;
    
        location / {
            root  /files;
            autoindex on;
            autoindex_exact_size off;
            autoindex_localtime on;
            charset utf-8,gbk;
        }
    
        #error_page  404              /404.html;
    
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    }
  • 执行
    docker run -d -p 18080:80 -v /Users/ss/Desktop/nginx/nginx.conf:/etc/nginx/conf.d/default.conf -v /files:/files nginx:latest
posted @ 2021-07-29 17:39  WenderWang  阅读(243)  评论(2编辑  收藏  举报