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

CentOS7 Docker Nginx部署及運(yùn)行詳解

 更新時(shí)間:2017年08月10日 15:51:34   作者:lvk618  
這篇文章主要介紹了CentOS7 Docker Nginx部署及運(yùn)行詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

網(wǎng)上找了一些資料部署,出現(xiàn)不一樣的問(wèn)題,現(xiàn)在總結(jié)一下自己的部署流程。

1、資源準(zhǔn)備

Dockerfile文件

# "ported" by Adam Miller <maxamillion@fedoraproject.org> from 
#  https://github.com/fedora-cloud/Fedora-Dockerfiles 
# 
# Originally written for Fedora-Dockerfiles by 
#  scollier <scollier@redhat.com> 
 
FROM centos:centos7 
MAINTAINER The CentOS Project <cloud-ops@centos.org> 
 
RUN yum -y update; yum clean all 
RUN yum -y install epel-release tar ; yum clean all 
RUN yum -y install nginx ; yum clean all 
ADD nginx.conf /opt/deploy/nginx/nginx.conf 
RUN echo "daemon off;" >> /opt/deploy/nginx/nginx.conf 
#RUN curl https://git.centos.org/sources/httpd/c7/acf5cccf4afaecf3afeb18c50ae59fd5c6504910 \ 
#  | tar -xz -C /usr/local/nginx/html \ 
#  --strip-components=1 
#RUN sed -i -e 's/Apache/nginx/g' -e '/apache_pb.gif/d' \  
#  /usr/local/nginx/html/index.html 
 
EXPOSE 80 
 
#CMD [ "/usr/local/nginx/sbin" ] 

注意:路徑需要在系統(tǒng)上面存在以及對(duì)應(yīng)

nginx.conf文件

# For more information on configuration, see: 
#  * Official English Documentation: http://nginx.org/en/docs/ 
#  * Official Russian Documentation: http://nginx.org/ru/docs/ 
 
user nginx; 
worker_processes 1; 
 
error_log /usr/logs/nginx/error.log; 
#error_log /var/log/nginx/error.log notice; 
#error_log /var/log/nginx/error.log info; 
 
pid    /run/nginx.pid; 
 
 
events { 
  worker_connections 1024; 
} 
 
 
http { 
  include    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 /usr/logs/nginx/access.log main; 
 
  sendfile    on; 
  #tcp_nopush   on; 
 
  #keepalive_timeout 0; 
  keepalive_timeout 65; 
 
  #gzip on; 
 
  # Load modular configuration files from the /etc/nginx/conf.d directory. 
  # See http://nginx.org/en/docs/ngx_core_module.html#include 
  # for more information. 
  #include /etc/nginx/conf.d/*.conf; 
 
  index  index.html index.htm; 
 
  server { 
    listen    80; 
    server_name localhost; 
    root     /usr/share/nginx/html; 
 
    #charset koi8-r; 
 
    #access_log /var/log/nginx/host.access.log main; 
 
    location / { 
      autoindex on; 
    } 
 
    # redirect server error pages to the static page /40x.html 
    # 
    error_page 404       /404.html; 
    location = /40x.html { 
    } 
 
    # redirect server error pages to the static page /50x.html 
    # 
    error_page  500 502 503 504 /50x.html; 
    location = /50x.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; 
    #} 
  } 
 
 
  # another virtual host using mix of IP-, name-, and port-based configuration 
  # 
  #server { 
  #  listen    8000; 
  #  listen    somename:8080; 
  #  server_name somename alias another.alias; 
  #  root     html; 
 
  #  location / { 
  #  } 
  #} 
 
 
  # HTTPS server 
  # 
  #server { 
  #  listen    443; 
  #  server_name localhost; 
  #  root     html; 
 
  #  ssl         on; 
  #  ssl_certificate   cert.pem; 
  #  ssl_certificate_key cert.key; 
 
  #  ssl_session_timeout 5m; 
 
  #  ssl_protocols SSLv2 SSLv3 TLSv1; 
  #  ssl_ciphers HIGH:!aNULL:!MD5; 
  #  ssl_prefer_server_ciphers  on; 
 
  #  location / { 
  #  } 
  #} 
 
} 

注意:路徑需要在系統(tǒng)上面存在以及對(duì)應(yīng)

2、執(zhí)行構(gòu)建鏡像命令

復(fù)制代碼 代碼如下:

[root@localhost nginx]# sudo docker build --rm --tag os7/nginx:centos7 . 

執(zhí)行結(jié)果截圖:

3、查看鏡像是否安裝構(gòu)建成功 Docker images

4、創(chuàng)建容器 docker run -i -t -d -p 192.168.32.129:81:80 os7/nginx /bin/bash

注意:192.168.32.129這個(gè)IP的話,則需要在/etc/hosts中添加

192.168.32.129     localhost

5、查看容器是否創(chuàng)建成功并啟動(dòng) docker ps

6、測(cè)試是否成功訪問(wèn) curl http://192.168.32.129:81

會(huì)出現(xiàn)這個(gè)拒絕連接,那怎么辦呢?有辦法解決的,我們先進(jìn)入該容器里面

7、進(jìn)入容器 docker exec -i -t small_hodgkin /bin/sh

8、接著在容器里面執(zhí)行(直接輸入即可)

nginx

9、在容器外面執(zhí)行 curl http://192.168.32.129:81

成功了。

10、再到虛擬機(jī)外面通過(guò)瀏覽器訪問(wèn)

到此為止就成功了。

參考資料:https://github.com/CentOS/CentOS-Dockerfiles

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

相關(guān)文章

  • Apache Airflow 快速入門教程應(yīng)用場(chǎng)景分析

    Apache Airflow 快速入門教程應(yīng)用場(chǎng)景分析

    ApacheAirflow是一個(gè)用于編排、調(diào)度和監(jiān)控工作流的開源平臺(tái),適用于ETL和MLOps用例,它通過(guò)有向無(wú)環(huán)圖(DAG)定義管道,支持任務(wù)依賴關(guān)系、調(diào)度、錯(cuò)誤處理和日志記錄,本文介紹Apache Airflow 快速入門教程,感興趣的朋友一起看看吧
    2024-12-12
  • Centos6.5全自動(dòng)安裝 vsftpd+dhcp+nfs+tftp

    Centos6.5全自動(dòng)安裝 vsftpd+dhcp+nfs+tftp

    本文主要記述了在Centos6.5中,如何配置無(wú)人值守安裝vsftpd+dhcp+nfs+tftp,非常實(shí)用,希望對(duì)大家能有所幫助。
    2014-09-09
  • linux下php-fpm開啟關(guān)閉使用方法

    linux下php-fpm開啟關(guān)閉使用方法

    自php5.3.3開始,php源碼中包含了php-fpm,不需要單獨(dú)通過(guò)補(bǔ)丁的方式安裝php-fpm,在源碼安裝的時(shí)候直接 configure 中增加參數(shù) –enable-fpm即可,使用方法如下
    2014-03-03
  • centos 7 源碼安裝openssh的方法

    centos 7 源碼安裝openssh的方法

    這篇文章主要介紹了centos 7 源碼安裝openssh的方法,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-06-06
  • 對(duì)linux下軟件(庫(kù))的更新命令詳解

    對(duì)linux下軟件(庫(kù))的更新命令詳解

    今天小編就為大家分享一篇對(duì)linux下軟件(庫(kù))的更新命令詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-07-07
  • 詳解linux系統(tǒng)目錄sys,tmp,usr,var!

    詳解linux系統(tǒng)目錄sys,tmp,usr,var!

    在本篇文章里小編給大家詳解了關(guān)于linux系統(tǒng)目錄,sys,tmp,usr,var!的相關(guān)知識(shí)點(diǎn)內(nèi)容,有興趣的朋友們參考下。
    2019-06-06
  • Linux內(nèi)核設(shè)備驅(qū)動(dòng)之proc文件系統(tǒng)筆記整理

    Linux內(nèi)核設(shè)備驅(qū)動(dòng)之proc文件系統(tǒng)筆記整理

    今天小編就為大家分享一篇關(guān)于Linux內(nèi)核設(shè)備驅(qū)動(dòng)之proc文件系統(tǒng)筆記整理,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2018-12-12
  • ubuntu 16.04 64位兼容32位程序三步曲

    ubuntu 16.04 64位兼容32位程序三步曲

    這篇文章主要介紹了ubuntu 16.04 64位兼容32位程序的三步,本文分步驟給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值 ,需要的朋友可以參考下
    2019-06-06
  • linux 普通用戶切換成root免密碼的實(shí)現(xiàn)

    linux 普通用戶切換成root免密碼的實(shí)現(xiàn)

    下面小編就為大家?guī)?lái)一篇linux 普通用戶切換成root免密碼的實(shí)現(xiàn)。小編覺得挺不錯(cuò)的?,F(xiàn)在就分享給大家。也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-12-12
  • ubuntu下安裝程序的三種方法總結(jié)(推薦)

    ubuntu下安裝程序的三種方法總結(jié)(推薦)

    下面小編就為大家?guī)?lái)一篇ubuntu下安裝程序的三種方法總結(jié)(推薦)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-12-12

最新評(píng)論

涿鹿县| 衢州市| 尖扎县| 定西市| 洛宁县| 安乡县| 革吉县| 西吉县| 泽州县| 石台县| 阳新县| 海口市| 江孜县| 灵石县| 盖州市| 崇文区| 洛川县| 蓬溪县| 华安县| 五常市| 莱阳市| 建平县| 久治县| 西峡县| 东丰县| 淄博市| 若尔盖县| 漳平市| 启东市| 屏边| 新沂市| 江津市| 罗田县| 新绛县| 自治县| 晴隆县| 寿光市| 淳化县| 安顺市| 庐江县| 时尚|