zoukankan      html  css  js  c++  java
  • Dockerfile基于centos镜像编译安装httpd

    Docker基于centos镜像编译安装httpd

    项目目录:

    [root@localhost ~]# tree
    .
    ├── anaconda-ks.cfg
    └── apache
        ├── Dockerfile
        └── packages
            ├── apr-1.7.0.tar.gz
            ├── apr-util-1.6.1.tar.gz
            └── httpd-2.4.46.tar.bz2
    

    制作httpd镜像的Dockerfile

    [root@localhost ~]# vim apache/Dockerfile 
    
    FROM centos
    
    LABEL MAINTAINER='leidazhuang 123@qq.com'
    
    ENV apr_version=1.7.0 apr_util_version=1.6.1 httpd_version=2.4.46
    
    ADD packages/apr-${apr_version}.tar.gz /usr/src
    ADD packages/apr-util-${apr_util_version}.tar.gz /usr/src
    ADD packages/httpd-${httpd_version}.tar.bz2 /usr/src
    
    RUN yum -y install make gcc gcc-c++ openssl-devel pcre-devel expat-devel libtool libxml2-devel &&
        useradd -r -M -s /sbin/nologin apache &&
        cd /usr/src/apr-${apr_version} &&
        sed -i '/$RM "$cfgfile"/d' configure &&
        ./configure --prefix=/usr/local/apr && make && make install &&
        cd /usr/src/apr-util-${apr_util_version} &&
        ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr &&
        make && make install &&
        cd /usr/src/httpd-${httpd_version} &&
        ./configure --prefix=/usr/local/apache 
        --sysconfdir=/etc/httpd24 
        --enable-so 
        --enable-ssl 
        --enable-cgi 
        --enable-rewrite 
        --with-zlib 
        --with-pcre 
        --with-apr=/usr/local/apr 
        --with-apr-util=/usr/local/apr-util/ 
        --enable-modules=most 
        --enable-mpms-shared=all 
        --with-mpm=prefork && make && make install &&
        sed -i '/#ServerName/s/#//g' /etc/httpd24/httpd.conf
    
    WORKDIR /usr/local/apache
    
    EXPOSE 80 443
    
    ENTRYPOINT /usr/local/apache/bin/apachectl  -DFOREGROUND
    

    创建镜像

    [root@localhost apache]docker build -t httpd:v0.1 /root/apache/
    
    Step 10/10 : ENTRYPOINT /usr/local/apache/bin/apachectl  -DFOREGROUND
     ---> Running in 066680bb2291
    Removing intermediate container 066680bb2291
     ---> 2acab10c568a
    Successfully built 2acab10c568a
    Successfully tagged httpd:v0.1
    

    启动容器,开放端口

    [root@localhost apache]# docker run -it --rm --name ldz -p 80:80 httpd:v0.1
    # 正常运行
    

    查看端口信息

    [root@localhost ~]# ss -antl
    State       Recv-Q      Send-Q           Local Address:Port           Peer Address:Port      
    LISTEN      0           128                    0.0.0.0:22                  0.0.0.0:*         
    LISTEN      0           128                    0.0.0.0:80                  0.0.0.0:*         
    LISTEN      0           128                       [::]:22                     [::]:* 
    

    访问测试

    [root@localhost ~]# curl 192.168.110.20
    <html><body><h1>It works!</h1></body></html>
    

    通过网页访问

  • 相关阅读:
    查询快递单号-宅急送快递接口
    对路由转发的浅显理解
    对SpringCloud Zuul 的基本使用总结
    对SpringCloud Hystrix的使用个人总结
    对SpringBoot开箱即用使用方法的浅显理解
    对SpringCloud Hystrix服务降级的浅显理解
    金玉良言
    2种运行时织入的动态代理模式原理和调用流程比较
    记录手动启动Oracle数据库的方式
    基于SpringBoot搭建一个带数据库访问的WEB项目(记录所需的依赖,配置,驱动安装等注意事项)
  • 原文地址:https://www.cnblogs.com/leixixi/p/14499685.html
Copyright © 2011-2022 走看看