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

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

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

這里來安裝下Nginx試下。

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

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

看到只有一個測試的鏡像。

拉取鏡像:

下載成功后查看,鏡像已經(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)時間</title>
</head>
<body>
<h1 id="datetime">
  <script>
    setInterval("document.getElementById('datetime').innerHTML=new Date().toLocaleString();", 1000);
  </script>
</h1>
</body>

刪除容器

docker rm -f nginx-test

重新映射啟動容器

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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • docker-entrypoint.sh文件的用處詳解

    docker-entrypoint.sh文件的用處詳解

    這篇文章主要介紹了docker-entrypoint.sh文件的用處,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • docker部署nginx及nginx.conf文件配置方式

    docker部署nginx及nginx.conf文件配置方式

    這篇文章主要介紹了docker部署nginx及nginx.conf文件配置方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • Docker入門安裝教程(小白篇)

    Docker入門安裝教程(小白篇)

    這篇文章主要介紹了Docker入門安裝教程(小白篇),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-01-01
  • 使用docker搭建jenkins自動化工具的實(shí)現(xiàn)

    使用docker搭建jenkins自動化工具的實(shí)現(xiàn)

    大家在工作中,應(yīng)該都有使用過jenkins 自動化打包或發(fā)布,本文主要介紹了使用docker搭建jenkins自動化工具的實(shí)現(xiàn),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • 如何查看docker中mysql的版本問題

    如何查看docker中mysql的版本問題

    這篇文章主要介紹了如何查看docker中mysql的版本問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-04-04
  • 解決'nacos默認(rèn)secret.key配置不當(dāng)權(quán)限繞過漏洞'的問題

    解決'nacos默認(rèn)secret.key配置不當(dāng)權(quán)限繞過漏洞'的問題

    這篇文章主要介紹了解決“nacos默認(rèn)secret.key配置不當(dāng)權(quán)限繞過漏洞“的問題,解決這個問題需要對這個key的默認(rèn)值進(jìn)行修改,建議不要使用明文,可以用base64,key的長度要32位以上,下面介紹一下在兩種環(huán)境下的修改方法,感興趣的朋友一起看看吧
    2024-01-01
  • 對已有的docker容器增加新的端口映射問題(兩種方式)

    對已有的docker容器增加新的端口映射問題(兩種方式)

    這篇文章主要介紹了對已有的docker容器增加新的端口映射,在運(yùn)行容器時指定映射端口運(yùn)行后,如果想要添加新的端口映射,使用兩種方式都可以,需要的朋友可以參考下
    2022-01-01
  • win10中docker部署和運(yùn)行countly-server的流程

    win10中docker部署和運(yùn)行countly-server的流程

    這篇文章主要記錄一下windows10中使用docker容器安裝和部署countly-server的整個流程,本文給大家講解的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友參考下吧
    2019-11-11
  • docker中的link和network網(wǎng)絡(luò)互連問題

    docker中的link和network網(wǎng)絡(luò)互連問題

    這篇文章主要介紹了docker中的link和network網(wǎng)絡(luò)互連問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-11-11
  • dockerhub 鏡像拉取超時的解決方法

    dockerhub 鏡像拉取超時的解決方法

    DockerHub遇到鏡像拉取超時問題,現(xiàn)在可以通過修改倉庫地址為daocloud提供的鏡像地址解決,為用戶提供便捷的鏡像拉取服務(wù),感興趣的可以了解一下
    2024-10-10

最新評論