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

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

 更新時(shí)間:2017年08月10日 15:51:34   作者:lvk618  
這篇文章主要介紹了CentOS7 Docker Nginx部署及運(yùn)行詳解,小編覺(jué)得挺不錯(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)文章

  • 如何解決Linux下Too many open files問(wèn)題

    如何解決Linux下Too many open files問(wèn)題

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

    centos 6.5 oracle開(kāi)機(jī)自啟動(dòng)的環(huán)境配置詳解

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

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

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

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

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

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

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

    教你如何修改Linux遠(yuǎn)程登錄歡迎提示信息

    教你如何在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ò)配置實(shí)用程序,用于在Ubuntu系統(tǒng)中輕松管理和配置網(wǎng)絡(luò)設(shè)置。這篇文章主要介紹了Ubuntu 18.04 Server 設(shè)置靜態(tài)IP 的方法,需要的朋友可以參考下
    2018-11-11
  • Apache的status相關(guān)問(wèn)題解決辦法

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

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

    linux userdel 命令的使用

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

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

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

最新評(píng)論