zoukankan      html  css  js  c++  java
  • 使用Dockerfile创建源码nginx镜像

    1.Nginx Dockerfile

    #这是之前就创建好的带密钥登陆的sshd:dockerfile镜像
    FROM sshd:dockerfile MAINTAINER liufan
    "liufan_hana@163.com" ENV NGINX_VERSION 1.10.3 ENV OPENSSL_VERSION 1.0.2k ENV PCRE_VERSION 8.40 ENV ZLIB_VERSION 1.2.11 ENV BUILD_ROOT /usr/local/src/nginx #在软件安装之前可以自行修改yum源,确保安装的速度。 RUN yum -y install curl && yum -y install tar gcc gcc-c++ make perl zip unzip && mkdir -p $BUILD_ROOT && cd $BUILD_ROOT && curl https://ftp.pcre.org/pub/pcre/pcre-$PCRE_VERSION.zip -o $BUILD_ROOT/pcre-$PCRE_VERSION.zip && curl https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz -o $BUILD_ROOT/openssl-$OPENSSL_VERSION.tar.gz && curl http://www.zlib.net/zlib-$ZLIB_VERSION.tar.gz -o $BUILD_ROOT/zlib-$ZLIB_VERSION.tar.gz && curl https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o $BUILD_ROOT/nginx-$NGINX_VERSION.tar.gz && tar vzxf nginx-$NGINX_VERSION.tar.gz && unzip pcre-$PCRE_VERSION.zip && tar vzxf zlib-$ZLIB_VERSION.tar.gz && tar vzxf openssl-$OPENSSL_VERSION.tar.gz && cd nginx-$NGINX_VERSION && BUILD_CONFIG=" --prefix=/usr/local/nginx-$NGINX_VERSION --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --with-openssl=$BUILD_ROOT/openssl-$OPENSSL_VERSION --with-pcre=$BUILD_ROOT/pcre-$PCRE_VERSION --with-zlib=$BUILD_ROOT/zlib-$ZLIB_VERSION --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-threads " && mkdir -p /var/cache/nginx && ./configure $BUILD_CONFIG && make && make install && rm -rf $BUILD_ROOT #&& yum -y remove gcc gcc-c++ make perl zip unzip && rpm -e --nodeps gcc gcc-c++ make perl zip unzip && yum clean packages
    && yum clean all
    CMD [
    "nginx","-g","daemon off;"] EXPOSE 80 EXPOSE 443

    2.创建镜像

    docker build -t nginx:dockerfile .
    .......
    ......
    ....
    ..
    .
    make[1]: Leaving directory `/usr/local/src/nginx/nginx-1.10.3'
     ---> 87b84b668879
    Removing intermediate container e0488a726ade
    Step 8 : CMD nginx -g daemon off;
     ---> Running in d762af3bf8b8
     ---> 2d922ef6a49f
    Removing intermediate container d762af3bf8b8
    Step 9 : EXPOSE 80
     ---> Running in 63c51094471f
     ---> add4845cf761
    Removing intermediate container 63c51094471f
    Step 10 : EXPOSE 443
     ---> Running in 5b98828819e3
     ---> 4b49269178c5
    Removing intermediate container 5b98828819e3
    Successfully built 4b49269178c5

    3.测试

    [root@docker1 nginx_centos]# docker run -d -P nginx:dockerfile
    41aa3439d88226376da1740ab5c4c5dc723774dffd867eb90e54a31448b36908
    [root@docker1 nginx_centos]# 
    [root@docker1 nginx_centos]# 
    [root@docker1 nginx_centos]# docker ps
    CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                                                                  NAMES
    41aa3439d882        nginx:dockerfile    "nginx -g 'daemon of   4 seconds ago       Up 4 seconds        0.0.0.0:32773->22/tcp, 0.0.0.0:32772->80/tcp, 0.0.0.0:32771->443/tcp   clever_fermi        
    [root@docker1 nginx_centos]# curl 127.0.0.1:32772
    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
        body {
             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 and
    working. 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>
  • 相关阅读:
    Android中从一个Activity跳转到另一个Activity所经历的生命周期
    Android五种数据存储方式
    Android的Activity启动方式(模式)
    个人笔记--activity--basic
    activity的生命周期
    gradle和maven的区别
    node是什么
    npm是什么
    激光雷达与毫米波雷达区别讲解
    VSLAM技术框架详述
  • 原文地址:https://www.cnblogs.com/hana-alice/p/10083836.html
Copyright © 2011-2022 走看看