婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > Docker中運行nginx并掛載本地目錄到鏡像中的方法

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

熱門標簽:智能電話機器人坐席 申請400電話價格多少 涪陵商都400電話開通辦理 外呼系統不彈窗 柳州市機器人外呼系統報價 廈門營銷外呼系統平臺 云會外呼系統 安陽ai電銷機器人軟件 外呼系統的經營范圍

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 ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fa56f865bd26 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并掛載本地目錄到鏡像中的方法》,本文關鍵詞  Docker,中,運行,nginx,并,掛載,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Docker中運行nginx并掛載本地目錄到鏡像中的方法》相關的同類信息!
  • 本頁收集關于Docker中運行nginx并掛載本地目錄到鏡像中的方法的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 广东省| 上饶县| 体育| 南靖县| 巍山| 丹东市| 宝兴县| 昆山市| 镇雄县| 丰顺县| 南充市| 于田县| 龙州县| 旬阳县| 康马县| 克什克腾旗| 伊宁县| 万全县| 米泉市| 资兴市| 瑞金市| 桂平市| 西城区| 青州市| 海口市| 新蔡县| 九寨沟县| 沧州市| 高唐县| 榆社县| 江永县| 句容市| 屯昌县| 福海县| 宁晋县| 满城县| 原阳县| 乌拉特中旗| 上饶县| 龙胜| 晋城|