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

CentOS7 Docker Nginx部署及運行詳解

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

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

1、資源準備

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)這個拒絕連接,那怎么辦呢?有辦法解決的,我們先進入該容器里面

7、進入容器 docker exec -i -t small_hodgkin /bin/sh

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

nginx

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

成功了。

10、再到虛擬機外面通過瀏覽器訪問

到此為止就成功了。

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

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

相關(guān)文章

  • 如何解決Linux下Too many open files問題

    如何解決Linux下Too many open files問題

    Too many open files是Linux系統(tǒng)中常見的錯誤,從字面意思上看就是說程序打開的文件數(shù)過多,不過這里的files不單是文件的意思,也包括打開的通訊鏈接(比如socket),正在監(jiān)聽的端口等等,所以有時候也可以叫做句柄(handle),這個錯誤通常也可以叫做句柄數(shù)超出系統(tǒng)限制。
    2021-06-06
  • centos 6.5 oracle開機自啟動的環(huán)境配置詳解

    centos 6.5 oracle開機自啟動的環(huán)境配置詳解

    這篇文章主要介紹了centos 6.5 oracle開機自啟動的環(huán)境配置詳解的相關(guān)資料,需要的朋友可以參考下
    2017-01-01
  • Linux 中有效用戶組和初始用戶組的實現(xiàn)

    Linux 中有效用戶組和初始用戶組的實現(xiàn)

    這篇文章主要介紹了Linux 中有效用戶組和初始用戶組的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • Linux系統(tǒng)命令中screen命令詳解

    Linux系統(tǒng)命令中screen命令詳解

    screen是可以在同一個遠程登陸會話窗口中創(chuàng)建多個screen會話窗口,當(dāng)會話暫時可以不需要的時候,可以放至后臺運行,雖然LINUX下提供&命令將程序放置后臺運行,但是對于人機交互的任務(wù)(比如在MySQL中運行一個長任務(wù)),還是screen比較勝任一點。下面來看看詳細的介紹吧。
    2016-12-12
  • linux中tar打包指定路徑文件的實現(xiàn)方法

    linux中tar打包指定路徑文件的實現(xiàn)方法

    下面小編就為大家?guī)硪黄猯inux中tar打包指定路徑文件的實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-12-12
  • 教你如何修改Linux遠程登錄歡迎提示信息

    教你如何修改Linux遠程登錄歡迎提示信息

    教你如何在Linux中創(chuàng)建登錄歡迎提示信息,要登錄或登錄后的用戶顯示不同的警告或消息
    2018-03-03
  • Ubuntu 18.04 Server 設(shè)置靜態(tài)IP 的方法

    Ubuntu 18.04 Server 設(shè)置靜態(tài)IP 的方法

    Netplan是Ubuntu 17.10中引入的一種新的命令行網(wǎng)絡(luò)配置實用程序,用于在Ubuntu系統(tǒng)中輕松管理和配置網(wǎng)絡(luò)設(shè)置。這篇文章主要介紹了Ubuntu 18.04 Server 設(shè)置靜態(tài)IP 的方法,需要的朋友可以參考下
    2018-11-11
  • Apache的status相關(guān)問題解決辦法

    Apache的status相關(guān)問題解決辦法

    這篇文章主要介紹了Apache的status相關(guān)問題解決辦法,文中環(huán)境為Linux系統(tǒng),需要的朋友可以參考下
    2015-07-07
  • linux userdel 命令的使用

    linux userdel 命令的使用

    這篇文章主要介紹了linux userdel 命令的使用,幫助大家更好的理解和使用Linux系統(tǒng),感興趣的朋友可以了解下
    2020-08-08
  • Linux PXE高效批量網(wǎng)絡(luò)裝機過程

    Linux PXE高效批量網(wǎng)絡(luò)裝機過程

    PXE(預(yù)啟動執(zhí)行環(huán)境)是一種網(wǎng)絡(luò)引導(dǎo)技術(shù),允許從遠程服務(wù)器通過網(wǎng)絡(luò)下載引導(dǎo)鏡像來安裝操作系統(tǒng),本文介紹了PXE的優(yōu)點如規(guī)?;?、自動化和遠程實現(xiàn),以及搭建PXE服務(wù)器的基本步驟,包括安裝和配置TFTP、DHCP服務(wù)
    2024-09-09

最新評論