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

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

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

網(wǎng)上找了一些資料部署,出現(xià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)上面存在以及對應(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)上面存在以及對應(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這個IP的話,則需要在/etc/hosts中添加

192.168.32.129     localhost

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

6、測試是否成功訪問 curl http://192.168.32.129:81

會出現(xiàn)這個拒絕連接,那怎么辦呢?有辦法解決的,我們先進(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ī)外面通過瀏覽器訪問

到此為止就成功了。

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

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

相關(guān)文章

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

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

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

    Centos6.5全自動安裝 vsftpd+dhcp+nfs+tftp

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

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

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

    centos 7 源碼安裝openssh的方法

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

    對linux下軟件(庫)的更新命令詳解

    今天小編就為大家分享一篇對linux下軟件(庫)的更新命令詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    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)知識點(diǎn)內(nèi)容,有興趣的朋友們參考下。
    2019-06-06
  • Linux內(nèi)核設(shè)備驅(qū)動之proc文件系統(tǒng)筆記整理

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

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

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

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

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

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

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

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

最新評論

宁明县| 高陵县| 陕西省| 长武县| 禹城市| 石狮市| 泰州市| 平泉县| 五家渠市| 长顺县| 桂东县| 石狮市| 墨江| 资兴市| 稷山县| 柘荣县| 土默特右旗| 望江县| 潼关县| 徐州市| 平乐县| 哈密市| 台中县| 渑池县| 德昌县| 牡丹江市| 元谋县| 遂昌县| 达孜县| 额尔古纳市| 贞丰县| 辽源市| 中方县| 客服| 弋阳县| 旬邑县| 满城县| 新沂市| 吉安市| 雅江县| 伊吾县|