欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時間:2019年01月04日 10:31:01   作者:海亮。  
這篇文章主要介紹了Docker中運行nginx并掛載本地目錄到鏡像中的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

1 從hup上pull鏡像

docker pull nginx

2 創(chuàng)建將要掛載的目錄

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 網(wǎng)頁訪問nginx

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Docker安裝方法與Docker四種網(wǎng)絡(luò)模式詳解

    Docker安裝方法與Docker四種網(wǎng)絡(luò)模式詳解

    今天小編就為大家分享一篇關(guān)于Docker安裝方法與Docker四種網(wǎng)絡(luò)模式的詳解,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2018-09-09
  • CentOS 7.x docker使用overlay2存儲方式

    CentOS 7.x docker使用overlay2存儲方式

    這篇文章主要介紹了CentOS 7.x docker使用overlay2存儲方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-11-11
  • Docker  Registry 私有倉庫搭建詳細(xì)步驟

    Docker Registry 私有倉庫搭建詳細(xì)步驟

    這篇文章主要介紹了Docker Registry 私有倉庫搭建的相關(guān)資料,需要的朋友可以參考下
    2016-10-10
  • Windows?Server?2012?R2?安裝?Docker的詳細(xì)步驟

    Windows?Server?2012?R2?安裝?Docker的詳細(xì)步驟

    這篇文章主要介紹了Windows?Server?2012?R2?安裝?Docker,在這個給大家說明下使用windows10、Windows?Server?2016以上系統(tǒng)可直接使用安裝包,低版本系統(tǒng)需要使用?Docker?Toolbox?來進行安裝使用?Docker,需要的朋友可以參考下
    2022-04-04
  • 詳解使用export/import導(dǎo)出和導(dǎo)入docker容器

    詳解使用export/import導(dǎo)出和導(dǎo)入docker容器

    本篇文章主要介紹了詳解使用export/import導(dǎo)出和導(dǎo)入docker容器,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-07-07
  • docker 安裝nacos并配置數(shù)據(jù)庫的教程詳解

    docker 安裝nacos并配置數(shù)據(jù)庫的教程詳解

    這篇文章主要介紹了docker 安裝nacos并配置數(shù)據(jù)庫的教程詳解,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-12-12
  • jenkins中通過Publish Over SSH插件將項目部署到遠(yuǎn)程機器上的講解說明

    jenkins中通過Publish Over SSH插件將項目部署到遠(yuǎn)程機器上的講解說明

    今天小編就為大家分享一篇關(guān)于jenkins中通過Publish Over SSH插件將項目部署到遠(yuǎn)程機器上的講解說明,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2019-02-02
  • win7環(huán)境下Docker快速構(gòu)建及阿里云容器加速配置詳解

    win7環(huán)境下Docker快速構(gòu)建及阿里云容器加速配置詳解

    這篇文章主要介紹了win7環(huán)境下Docker快速構(gòu)建及阿里云容器加速配置詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09
  • docker?搭建?ElasticSearch過程解析

    docker?搭建?ElasticSearch過程解析

    這篇文章主要介紹了docker搭建ElasticSearch的過程,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,,需要的朋友可以參考下
    2023-08-08
  • Docker跨主機網(wǎng)絡(luò)(overlay)的實現(xiàn)

    Docker跨主機網(wǎng)絡(luò)(overlay)的實現(xiàn)

    這篇文章主要介紹了Docker跨主機網(wǎng)絡(luò)(overlay)的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12

最新評論