Dockerfile + 源码安装httpd 制作镜像

Dockerfile + 源码安装httpd 制作镜像

环境:

虚拟机版本ip部署应用
centos8192.168.136.142docker
[root@localhost ~]# ls
anaconda-ks.cfg  httpd
[root@localhost httpd]# cat dockerfile 
FROM centos

RUN rm -rf /etc//yum.repos.d/* && \
    curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo && \ 
    sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo && \
    yum clean all && yum makecache && \
    yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make wget && \
    wget https://downloads.apache.org/apr/apr-1.7.4.tar.gz -P /usr/src/ && \
    wget https://downloads.apache.org/apr/apr-util-1.6.3.tar.gz -P /usr/src/ && \
    wget http://archive.apache.org/dist/httpd/httpd-2.4.57.tar.gz -P /usr/src/ && \
    cd /usr/src/ && \
    tar -xf apr-1.7.4.tar.gz && \
    cd apr-1.7.4 && \
    sed -i 's/$RM "$cfgfile"/#$RM "$cfgfile"/g' configure && \
    ./configure --prefix=/usr/local/apr && \
    make -j4 && make install && \
    cd .. && \
    tar -xf apr-util-1.6.3.tar.gz && \
    cd apr-util-1.6.3 && \
    ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && \
    make -j4 && make install && \
    cd .. && \
    groupadd -r apache && useradd -r -M -s /sbin/nologin -g apache apache && \
    tar -xf httpd-2.4.57.tar.gz && \
    cd httpd-2.4.57 && \
    ./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 -j4 && make install && \
    echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh && \
    ln -s /usr/local/apache/include/ /usr/include/httpd && \
    echo 'MANPATH /usr/local/apache/man' >> /etc/man.config && \
    sed -i '/#ServerName/s/#//g' /etc/httpd24/httpd.conf && \
    echo "<html><body><h1>nice moon!</h1></body></html>" > /usr/local/apache/htdocs/index.html && \
    /usr/local/apache/bin/apachectl start && \
    cd /usr/src &&  rm -rf a* h*

CMD ["/usr/local/apache/bin/httpd","-X","-D","FOREGROUND"]
[root@localhost httpd]# 


[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
apache       v0.1      0da42f466317   7 minutes ago   574MB

[root@localhost ~]# docker tag apache:v0.1 ttq6/apache:v60
[root@localhost ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED          SIZE
apache        v0.1      0da42f466317   12 minutes ago   574MB
ttq6/apache   v60       0da42f466317   12 minutes ago   574MB
[root@localhost ~]# 

# 上传
[root@localhost ~]# docker login
Authenticating with existing credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@localhost ~]# docker push ttq6/apache:v60
The push refers to repository [docker.io/ttq6/apache]
f2ec17d60d70: Pushed 
74ddd0ec08fa: Mounted from library/centos 
v60: digest: sha256:7be69493a716957cfdb2e42e95db3b8b6ded82cadabe5888c0333b85fad1d5d9 size: 742
[root@localhost ~]# 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值