麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 網站 > Nginx > 正文

CentOS7 Docker Nginx部署及運行詳解

2024-08-30 12:29:06
字體:
來源:轉載
供稿:網友

網上找了一些資料部署,出現不一樣的問題,現在總結一下自己的部署流程。

1、資源準備

Dockerfile文件

# "ported" by Adam Miller <[email protected]> from #  https://github.com/fedora-cloud/Fedora-Dockerfiles # # Originally written for Fedora-Dockerfiles by #  scollier <[email protected]>  FROM centos:centos7 MAINTAINER The CentOS Project <[email protected]>  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" ] 

注意:路徑需要在系統上面存在以及對應

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 / {   #  }   #}  } 

注意:路徑需要在系統上面存在以及對應

2、執行構建鏡像命令

 

復制代碼 代碼如下:

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

 

執行結果截圖:

CentOS7,Docker,Nginx部署

3、查看鏡像是否安裝構建成功 Docker images

CentOS7,Docker,Nginx部署

4、創建容器 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、查看容器是否創建成功并啟動 docker ps

CentOS7,Docker,Nginx部署

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

CentOS7,Docker,Nginx部署

會出現這個拒絕連接,那怎么辦呢?有辦法解決的,我們先進入該容器里面

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

CentOS7,Docker,Nginx部署

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

nginx

9、在容器外面執行 curl http://192.168.32.129:81

CentOS7,Docker,Nginx部署

成功了。

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

CentOS7,Docker,Nginx部署

到此為止就成功了。

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

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 成人免费区 | 国产午夜精品一区二区三区嫩草 | 91网址在线播放 | 国产成人小视频在线观看 | 毛片国产 | 成人福利软件 | 亚洲91精品| 免费一级毛片在线播放视频 | 久久综合九色综合久久久精品综合 | 精品一区二区久久久久 | 手机av免费在线 | 日韩精品久久久 | 国产精品探花在线观看 | 久久精品视频69 | 羞羞草视频 | 亚洲精品欧美二区三区中文字幕 | 亚洲性在线视频 | 久久国产综合精品 | 国产精品av久久久久久网址 | 97久色| 日韩美香港a一级毛片 | 亚洲精品久久久久久 | 在线视频1区 | 麻豆视频国产在线观看 | 久草在线新视觉 | 日韩理论电影网 | 亚洲一区在线免费视频 | 精品国产一区二区三区四区在线 | 在线成人影视 | 久久撸视频 | 国产五区 | 亚洲第一视频 | 国产高潮好爽受不了了夜色 | 精品久久久久久久久久中出 | 欧美精品18videos性欧美 | 午夜视频福利 | gril hd| 久久网站热最新地址4 | 双性精h调教灌尿打屁股的文案 | 国产精品亚洲欧美一级在线 | 免费一级毛片免费播放 |