docker安装nginx
admin
2023-02-28 20:21:06
0

1.查找镜像

docker search nginx

docker安装nginx

2.拉取镜像

docker pull nginx

docker安装nginx

3.创建挂载目录

mkdir conf

mkdir develop

ls

docker安装nginx

4.进入conf目录,创建nginx.conf配置文件

# gzip设置

gzip on;

gzip_vary on;


gzip_comp_level 6;

gzip_buffers 16 8k;


gzip_min_length 1000;

gzip_proxied any;

gzip_disable "msie6";

#gzip_http_version 1.0;

gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;


server {

    listen       80;

    server_name  localhost;


    #charset koi8-r;

    #access_log  /var/log/nginx/host.access.log  main;


    #location / {

        #root   /usr/share/nginx/html;

        #index  index.html index.htm;

        # 其作用是按顺序检查文件是否存在,返回第一个找到的文件或文件夹(结尾加斜线表示为文件夹),如果所有的文件或文件夹都找不到,会进行一个内部重定向到最后一个参数。

        #try_files $uri /index.html;

    #}


    location / {

        root    /usr/share/nginx/html;

        index   index.html index.htm;

    }


    #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;

    }


    # proxy the PHP scripts to Apache listening on 127.0.0.1:80

    #

    #location ~ \.php$ {

    #    proxy_pass   http://127.0.0.1;

    #}


    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

    #

    #location ~ \.php$ {

    #    root           html;

    #    fastcgi_pass   127.0.0.1:9000;

    #    fastcgi_index  index.php;

    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

    #    include        fastcgi_params;

    #}


    # deny access to .htaccess files, if Apache's document root

    # concurs with nginx's one

    #

    #location ~ /\.ht {

    #    deny  all;

    #}

}

5.启动容器

docker run --name nginx -p 80:80 --privileged=true -v /usr/local/docker/nginx/conf/nginx.conf:/etc/nginx/conf.d/default.conf -v /usr/local/docker/nginx/develop/dist/:/usr/share/nginx/html/ -d nginx
docker安装nginx

6.查看容器状态
docker安装nginx

7.测试


相关内容

热门资讯

谢晓亮追忆科学狂人文特尔:一位... 来源:市场资讯 (来源:知识分子) 克雷格·文特尔(Craig Venter) 撰文|谢晓亮 20...
三星史上最大罢工逼近:为期18... 快科技5月7日消息,据媒体报道,三星电子旗下最大的工会组织——三星全国工会(NSEU)已宣布,计划于...
AI模型是个黑箱,这家公司造了... (来源:麻省理工科技评论) 旧金山初创公司 Goodfire 刚刚发布了一款叫 Silico 的新工...
原创 俄... “这并非偶然相遇——宇宙2583号卫星执行了多次精细机动,以维持这种近距离构型。” 一枚安加拉火箭...
原创 马... 马斯克在德州超级工厂接受访谈的时候,抛出三大直指普通人命运的 AI 预言,引发广泛讨论。下文将逐一拆...
原创 6... 这段时间多家手机厂商旗下手机都卖得更贵了,因为储存元器件涨价,导致它们的成本上涨,不过华为手机不一样...
2500亿估值的xAI,散了!... 出品|搜狐科技 作者|郑松毅 编辑|杨锦 马斯克一句话,估值2500亿美元的xAI,说散就散了。 数...
全球AI新王诞生!Anthro... 新智元报道 编辑:Aeneas 【新智元导读】1.2万亿美元!Anthropic 估值正式反超Op...
业内首个!小米开源模型Omni... 【CNMO科技消息】5月7日,小米AI实验室推出OmniVoice,这是业内首个覆盖数百语种的语音克...
国民党民代爆料水电商中标军事炸... 【环球网报道】据台湾中时新闻网5月7日报道,国民党籍民意代表马文君7日爆料,台“军备局”生产制造中心...