最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Docker安裝Nginx教程實(shí)現(xiàn)圖例講解

 更新時(shí)間:2020年09月22日 11:27:46   作者:手撕高達(dá)的村長  
這篇文章主要介紹了Docker安裝Nginx教程圖例講解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

這里來安裝下Nginx試下。

注意要明確一點(diǎn),鏡像是類,容器是對(duì)象。

查看當(dāng)前的鏡像

看到只有一個(gè)測試的鏡像。

拉取鏡像:

下載成功后查看,鏡像已經(jīng)被下載下來了:

使用 nginx 鏡像

運(yùn)行容器:

查看容器運(yùn)行情況:

然后在瀏覽器輸入網(wǎng)址:

修改文件:

[root@VM_0_4_centos bin]# docker ps
CONTAINER ID    IMAGE        COMMAND         CREATED       STATUS       PORTS        NAMES
 
8bf811453641    nginx        "nginx -g 'daemon of…"  4 minutes ago    Up 4 minutes    0.0.0.0:80->80/tcp  nginx_test

記住這里的 CONTAINER ID ,這是容器的ID

進(jìn)入容器,修改:

[root@VM_0_4_centos bin]# docker exec -it 8bf811453641 /bin/bash
root@8bf811453641:/# cd /usr/share/nginx/html
root@8bf811453641:/usr/share/nginx/html# echo "hello docker">index.html
root@8bf811453641:/usr/share/nginx/html# exit

這是查看,修改的已經(jīng)生效了。

如果想停止容器:

docker stop containerId // containerId 是容器的ID
[root@VM_0_4_centos bin]# docker stop 8bf811453641

然后用docker ps 看容器運(yùn)行狀態(tài)就行。

到此,容器運(yùn)行完畢,總體來說非常的簡單。

下面追加掛載方法先創(chuàng)建目錄

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

nginx配置文件

/data/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 - $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;

  server {
    listen    80;
    server_name localhost;

    #charset koi8-r;

    #access_log logs/host.access.log main;

    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  html;
    }

  }
  
  include /etc/nginx/conf.d/*.conf;
}

/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/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; 
  } 
 
  # 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; 
  #} 
}

/data/nginx/html/index.html

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>系統(tǒng)時(shí)間</title>
</head>
<body>
<h1 id="datetime">
  <script>
    setInterval("document.getElementById('datetime').innerHTML=new Date().toLocaleString();", 1000);
  </script>
</h1>
</body>

刪除容器

docker rm -f nginx-test

重新映射啟動(dòng)容器

docker run --name nginx-test -d -p 80: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

再次運(yùn)行

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

相關(guān)文章

  • docker實(shí)現(xiàn)MySQL主從雙備的示例代碼

    docker實(shí)現(xiàn)MySQL主從雙備的示例代碼

    本文主要介紹了docker實(shí)現(xiàn)MySQL主從雙備,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-01-01
  • 如何修改 docker 容器的啟動(dòng)參數(shù)

    如何修改 docker 容器的啟動(dòng)參數(shù)

    工作中我們經(jīng)常遇到docker容器運(yùn)行一段時(shí)間后,因?yàn)楦鞣N原因需要調(diào)整啟動(dòng)參數(shù)的情況,這篇文章主要介紹了如何修改 docker 容器的啟動(dòng)參數(shù),需要的朋友可以參考下
    2023-09-09
  • Docker 運(yùn)行多個(gè)Springboot的詳細(xì)教程

    Docker 運(yùn)行多個(gè)Springboot的詳細(xì)教程

    這篇文章主要介紹了Docker 運(yùn)行多個(gè)Springboot的詳細(xì)教程,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-12-12
  • Docker?制作tomcat鏡像并部署項(xiàng)目的步驟

    Docker?制作tomcat鏡像并部署項(xiàng)目的步驟

    這篇文章主要介紹了Docker?制作tomcat鏡像并部署項(xiàng)目?,講解如何制作自己的tomcat鏡像,并使用tomcat部署項(xiàng)目,需要的朋友可以參考下
    2022-10-10
  • docker compose方式如何安裝ClickHouse數(shù)據(jù)庫

    docker compose方式如何安裝ClickHouse數(shù)據(jù)庫

    這篇文章主要介紹了docker compose方式如何安裝ClickHouse數(shù)據(jù)庫問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2025-04-04
  • 詳解Docker下搭建Jenkins構(gòu)建環(huán)境

    詳解Docker下搭建Jenkins構(gòu)建環(huán)境

    這篇文章主要介紹了詳解Docker下搭建Jenkins構(gòu)建環(huán)境,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-05-05
  • Docker容器安裝Vim編輯器的方法

    Docker容器安裝Vim編輯器的方法

    Docker容器是一種輕量級(jí)、可移植的應(yīng)用程序打包解決方案,在本文中,我們將討論如何在Docker容器中安裝Vim編輯器,為容器增添一個(gè)功能強(qiáng)大的文本編輯器,感興趣的朋友跟隨小編一起看看吧
    2023-08-08
  • Idea通過docker compose?發(fā)布項(xiàng)目的過程

    Idea通過docker compose?發(fā)布項(xiàng)目的過程

    這篇文章主要介紹了Idea結(jié)合docker-compose發(fā)布項(xiàng)目,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-08-08
  • Docker如何安裝PostgreSQL

    Docker如何安裝PostgreSQL

    這篇文章主要介紹了Docker如何安裝PostgreSQL,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧
    2024-05-05
  • Docker容器中Mysql數(shù)據(jù)的導(dǎo)入/導(dǎo)出詳解

    Docker容器中Mysql數(shù)據(jù)的導(dǎo)入/導(dǎo)出詳解

    服務(wù)器在使用了 Docker 后,對(duì)于備份和恢復(fù)數(shù)據(jù)庫的事情做下記錄,下面這篇文章主要給大家介紹了Docker容器中Mysql數(shù)據(jù)導(dǎo)入/導(dǎo)出的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2018-09-09

最新評(píng)論

阿巴嘎旗| 天台县| 乌恰县| 白朗县| 济阳县| 三门县| 玉田县| 万安县| 新巴尔虎右旗| 昭通市| 包头市| 宾阳县| 福贡县| 丹阳市| 将乐县| 古丈县| 十堰市| 金川县| 新龙县| 罗田县| 萨迦县| 澜沧| 青河县| 巴林左旗| 普宁市| 新蔡县| 汾西县| 芷江| 威信县| 景德镇市| 汕头市| 大宁县| 青龙| 门头沟区| 黑山县| 三江| 舞钢市| 陵川县| 长治市| 巫溪县| 仙居县|