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.测试


相关内容

热门资讯

超50℃今年最高!新疆高温还会... 连日来,新疆持续高温。其中,新疆吐鲁番盆地7月以来热力不断飙升,国家级气象站气温纪录接连被刷新。目前...
男子用刀片割癌症晚期患者肿瘤,... 山东省临沂市罗庄区发生一起“伪大师”利用患者求生欲望疯狂敛财的诈骗案件。近日,被告人孙某因犯诈骗罪被...
凤凰女记者:美伊大战似乎一触即... 特朗普7月23日表示,他正在“认真考虑”重启对伊朗的大规模作战行动。据路透社报道,此前伊朗已向胡塞武...
特朗普称准备第四次竞选总统 据中国新闻社,当地时间7月25日,美国总统特朗普在白宫记者协会晚宴上戴上标志性小红帽,上面有“特朗普...
国家防总提升针对广东的应急响应... 今年第12号台风“红霞”已于7月25日早晨加强为台风级。预计,“红霞”将于25日夜间至26日早晨在香...
美媒爆猛料:两国首次直接袭击伊... 多名知情人士向美国《华尔街日报》透露,巴林和科威特在7月初对伊朗境内军事目标实施了秘密空袭,知情人士...
郑丽文:只有中国国民党可以确保... 据凤凰卫视报道,国民党今天(7月25日)举行“全代会”,党主席郑丽文与党内提名的县市长参选人一同造势...
透视上半年消费外贸外资走势 新华社北京7月23日电 题:稳中提质 韧性增强——透视上半年消费外贸外资走势新华社记者谢希瑶、王聿昊...
水龙头出水小怎么解决 水龙头出水小可能是由多种原因引起的,以下是一些常见的解决方法:1. 清洁水龙头:水龙头使用时间长了,...
小神童洗衣机启动后不出水直接洗 有可能是洗衣机的进水阀被烧坏了,需要换一个新的进水阀安装上即可。另外不建议自己擅自拆卸洗衣机内部进行...