Dockerfile

Dockerfile
 ############################################################
 # Dockerfile to build Nginx Installed Containers
 # Based on CentOS
 ############################################################
 # Set the base image to CentOS
 FROM centos
 # File Author / Maintainer
 MAINTAINER alex
 # Install necessary toolsRUN yum install -y pcre-devel wget net-tools gcc
 RUN yum install -y zlib zlib-devel make
 RUN yum install -y openssl-devel# Install Nginx
 ADD http://nginx.org/download/nginx-1.8.0.tar.gz .
 RUN tar zxvf nginx-1.8.0.tar.gz
 RUN mkdir -p /usr/local/nginxRUN cd nginx-1.8.0 && ./configure --prefix=/usr/local/nginx && make && make install
 RUN rm -fv /usr/local/nginx/conf/nginx.conf
 COPY .nginx_conf /usr/local/nginx/conf/nginx.conf
 # Expose ports
 EXPOSE 80
 # Set the default command to execute
 # when creating a new container
 CMD /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
创建镜像
 # docker build -t centos_nginx .Sending build context to Docker daemon   554 MBSending build context to Docker daemon Step 0 : FROM centos ---> bac949ce964bStep 1 : MAINTAINER aming aming@aminglinux.com ---> Using cache ---> c2065048b72aStep 2 : RUN yum install -y pcre-devel wget net-tools gcc ---> Using cache ---> 05fa4cc1856fStep 3 : RUN yum install -y zlib zlib-devel make ---> Using cache ---> 99960731c759Step 4 : RUN yum install -y openssl-devel ---> Using cache ---> 1f3cc9ae48cdStep 5 : ADD http://nginx.org/download/nginx-1.8.0.tar.gz .Downloading 832.1 kB/832.1 kB ---> Using cache ---> 16d6f68fea77Step 6 : RUN tar zxvf nginx-1.8.0.tar.gz ---> Using cache ---> 4df46e512943Step 7 : RUN mkdir -p /usr/local/nginx ---> Using cache ---> 865f9d97d9e5Step 8 : RUN cd nginx-1.8.0 && ./configure --prefix=/usr/local/nginx && make && make install ---> Using cache ---> b997c1dce057Step 9 : RUN rm -fv /usr/local/nginx/conf/nginx.conf ---> Using cache ---> 857e27129832Step 10 : COPY .nginx_conf /usr/local/nginx/conf/nginx.conf ---> 3a300ffbcfa3Removing intermediate container bc3bdb68a3c2Step 11 : EXPOSE 80 ---> Running in 6a8c267e92b6 ---> 20c46a5b0b57Removing intermediate container 6a8c267e92b6Step 12 : CMD /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ---> Running in 0b626e465eaa ---> 54caaabd2c3bRemoving intermediate container 0b626e465eaaSuccessfully built 54caaabd2c3b
启动

docker run -itd -P centos_nginx bash

docker exec -it 398a bash

398a6248bb74 centos_nginx "bash" 4 minutes ago Up 4 minutes 0.0.0.0:32768->80/tcp agitated_banach

 # curl 127.0.0.1:32768<!DOCTYPE html><html><head><title>Welcome to nginx!</title><style>    body {        width: 35em;        margin: 0 auto;        font-family: Tahoma, Verdana, Arial, sans-serif;    }</style></head><body><h1>Welcome to nginx!</h1><p>If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.</p><p>For online documentation and support please refer to<a href="http://nginx.org/">nginx.org</a>.<br/>Commercial support is available at<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p></body></html>

本文分享自微信公众号 - 从零开始的linux(gh_4a9d788f5f27),作者:零月

原文出处及转载信息见文内详细说明,如有侵权,请联系 yunjia_community@tencent.com 删除。

原始发表时间:2017-06-10

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • 安装nginx

    # yum install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-deve...

    零月
  • https证书

    获取certbot wget https://dl.eff.org/certbot-auto chmod a+x certbot-auto 安装nginx yu...

    零月
  • 版本变更

    版本变更 git仓库的记录操作 # git log --pretty=oneline ffab1af0c161e0992642d27e69d94f93ac95b...

    零月
  • Ngin服务学习(3)-yum安装ngi

    cat /etc/redhat-release 查看系统版本 uname -a 查看系统内核详情

    py3study
  • linux 下 nginx 安装echo扩展模块

    echo 模块可以将nginx 变量的信息输出到网页中。echo 模块对学习nginx 配置文件有很大帮助,对应调试nginx 配置文件中变量特步方便。想要深...

    地球流浪猫
  • 20步打造最安全的Nginx Web服务器(下)

    八、控制缓冲区溢出攻击 编辑nginx.conf,为所有客户端设置缓冲区的大小限制。 vi /usr/local/nginx/conf/nginx.conf ...

    小小科
  • nginx代理其他端口到80端口-低调小熊猫的技术小黑屋

    我最近遇到微信授权认证回调的一个坑,本地测试的时候,我是用的内网穿透+端口,一切ok。等我配置公众号平台时,才发现微信那边只支持80端口,公司项目80端口已经被...

    低调小熊猫
  • 在CentOS 7上安装Nginx服务器

    下面我就我在CentOS上安装Nginx经验做简单的记录,以备后查。 1、下载nginx-release包 以CentOS 7为例,下载nginx软件包:htt...

    庞小明
  • Linux[CentOS]下编译安装Nginx 步骤

    Nginx 是一个很牛的高性能Web和反向代理服务器, 它具有有很多非常优越的特性:

    无道
  • promethus监控nginx

    promethues监控nginx可选两个exporter,通过nginx_exporter主要是获取nginx-status中的内建的指标,nginx自身提供...

    py3study

扫码关注云+社区

领取腾讯云代金券