色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術(shù)文章
文章詳情頁

詳解docker nginx 容器啟動掛載到本地

瀏覽:38日期:2024-11-19 14:18:08

首先nginx容器內(nèi)部的結(jié)構(gòu):

進入容器:

docker exec -it b511b6049f57 bash

查看容器的結(jié)構(gòu)目錄:其實每一個容器就相當于一個獨立的系統(tǒng)。

root@b511b6049f57:/# lsbin dev home lib64mnt proc run srv tmp varboot etc lib mediaopt root sbin sys usr

nginx的結(jié)構(gòu)目錄在容器中:

日志位置:/var/log/nginx/ 配置文件位置:/etc/nginx/ 項目位置:/usr/share/nginx/html

如果你想在本地去添加location 需要把這些容器中的配置掛載到本地:

配置文件相對來說有點麻煩,一般nginx只需要加載nginx.conf就可以了,在dokcer中,是首先加載nginx.conf,然后在nginx.conf有這么一行include /etc/nginx/conf.d/*.conf;,就是加載conf.d目錄下的配置文件。所以對于配置只需要掛載到conf.d,覆蓋掉即可。

在本地創(chuàng)建對應(yīng)的文件夾和主配置文件nginx.conf:

mkdir -p /home/test/nginx/{log,conf,html}touch nginx.conf

nginx.conf包含子配置文件(最后一行):

user nginx;worker_processes 1;error_log /var/log/nginx/error.log warn;pid /var/run/nginx.pid;events { worker_connections 1024;}http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main ’'$remote_addr' '$http_host' '[$time_local]' '$request' '$status' '$body_bytes_sent' ’ ’'$bytes_sent' '$gzip_ratio' '$http_referer' '$http_user_agent' '$http_x_forwarded_for' ’ ’'$upstream_addr' '$upstream_response_time' '$request_time' '$request_body' '$http_authorization' ’; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf;}

在 conf下創(chuàng)建一個默認的default.conf:

server { listen 80; server_name localhost; #charset koi8-r; access_log /var/log/nginx/log/host.access.log main; location / { #root /data/nginx/html; root /usr/share/nginx/html; index index.html index.htm; #autoindex on; #try_files $uri /index/index/page.html; #try_files $uri /index/map/page.html; } #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; } location ~ /images { default_type application/json; return 200 ’{'code': 'A000000', 'message': 'ok', 'timestamp': '20180307184426', 'data': {'isvip': '1', 'monthProList': []}}’; } # 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; #}}

準備完成上面的本地文件以后開始啟動容器掛載到本地相關(guān)配置文件:

docker run --name docker_nginx -d -p 80:80 -v /home/test/nginx/log:/var/log/nginx -v /home/test/nginx/conf:/etc/nginx/conf.d -v /home/test/nginx/nginx.conf:/etc/nginx/nginx.conf -v /home/test/nginx/html:/usr/share/nginx/html nginx### 第一個-v:掛載日志目錄 第二個-v:掛載配置目錄 第三個-v:掛載主配置文件 第四個-v:掛載項目目錄

掛載完成以后訪問主頁面:

詳解docker nginx 容器啟動掛載到本地

然后在訪問我們之前在default寫的一個location /images:

詳解docker nginx 容器啟動掛載到本地

重啟nginx:

docker exec -it b511b6049f57 nginx -s reload

到此這篇關(guān)于詳解docker nginx 容器啟動掛載到本地的文章就介紹到這了,更多相關(guān)docker nginx啟動掛載內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標簽: Docker
相關(guān)文章:
主站蜘蛛池模板: 呦女亚洲一区精品 | 亚洲国产精品一区二区三区 | 在线成人 | 精品欧美日韩一区二区三区 | 国产成人精品视频播放 | 91丨九色丨首页在线观看 | 欧美日韩免费播放一区二区 | 国产成人免费永久播放视频平台 | 日本aaaa精品免费视频 | 久久视频6免费观看视频精品 | 免费国产成人18在线观看 | 亚洲性影院 | 成年人免费在线观看网站 | 成 人 a v免费视频 | 国产精品亲子乱子伦xxxx裸 | 成人综合在线观看 | 日本免费大黄在线观看 | 亚洲精品国产一区二区三区四区 | 亚洲国产一区在线精选 | aaa大片 | 国产精品一区二区三区久久 | 久久久久国产 | 亚州精品视频 | 久久99久久成人免费播放 | 在线精品国内外视频 | 成人影院欧美大片免费看 | 怡红院免费的全部视频 | 午夜剧场成年 | 好看的看黄a大片爽爽影院 好男人天堂网 | 九九视频在线观看视频6 | 日韩字幕一中文在线综合 | 九九久久久久午夜精选 | 99国产精品视频久久久久 | 日韩在线视频不卡一区二区三区 | 可以免费观看欧美一级毛片 | 亚洲欧美一二三区 | 国产亚洲一区二区三区在线 | 国产精品亚洲午夜不卡 | 精品欧美高清一区二区免费 | 欧美性色xo在线 | 怡红院精品视频 |