国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Nginx > 正文

Docker中運行nginx并掛載本地目錄到鏡像中的方法

2024-08-30 12:30:10
字體:
來源:轉載
供稿:網友

1 從hup上pull鏡像

docker pull nginx

2 創建將要掛載的目錄

mkdir -p /data/nginx/{conf,conf.d,html,logs}

3 先要有配置文件才能啟動容器

3.1 vim /data/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 - $remote_user [$time_local] "$request" '           '$status $body_bytes_sent "$http_referer" '           '"$http_user_agent" "$http_x_forwarded_for"';  access_log /var/log/nginx/access.log main;  sendfile    on;  #tcp_nopush   on;  keepalive_timeout 65;  #gzip on;  include /etc/nginx/conf.d/*.conf;}

3.2 vim /data/nginx/conf.d/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/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;   }    # 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;   #} }

4 啟動容器

#將容器中nginx的80端口映射到本地的81端口docker run --name nginx81 -d -p 81: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

5 查看啟動的容器

[root@dc01 ~]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESfa56f865bd26 nginx:latest "nginx -g 'daemon of…" 4 weeks ago Up 3 seconds 0.0.0.0:80->80/tcp vigilant_swirles[root@dc01 ~]# 

6 網頁訪問nginx

Docker,nginx,掛載,本地目錄,鏡像

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到服務器教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 麦盖提县| 伊吾县| 商都县| 忻城县| 麟游县| 四会市| 遂昌县| 兴文县| 清镇市| 昭苏县| 南郑县| 大余县| 天门市| 水城县| 临邑县| 瑞昌市| 探索| 平南县| 惠来县| 绥棱县| 伊宁市| 平武县| 五大连池市| 舞阳县| 健康| 吉林省| 富阳市| 黄大仙区| 浪卡子县| 北票市| 盱眙县| 南阳市| 和林格尔县| 宜良县| 合阳县| 吉木乃县| 松原市| 固镇县| 辛集市| 临清市| 红原县|