Dockerfile基于centos镜像编译安装httpd
[root@localhost ~]# tree
.
├── anaconda-ks.cfg
└── apache
├── Dockerfile
└── packages
├── apr-1.7.0.tar.bz2
├── apr-util-1.6.1.tar.bz2
└── httpd-2.4.53.tar.bz2
[root@localhost ~]# vim apache/Dockerfile
FROM centos
LABEL MAINTAINER='asd 1@2.com'
ENV apr_version=1.7.0 apr_util_version=1.6.1 httpd_version=2.4.53
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.gz /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 ~]# docker build -t httpd:v0.1 /root/apache/
Sending build context to Docker daemon 11.38MB
Step 1/10 : FROM centos
---> 5d0da3dc9764
Step 2/10 : LABEL MAINTAINER='asd 1@2.com'
---> Running in 6e7d93392d87
Removing intermediate container 6e7d93392d87
---> c856543e590e
Step 3/10 : ENV apr_version=1.7.0 apr_util_version=1.6.1 httpd_version=2.4.53
---> Running in 2415372092a0
Removing intermediate container 2415372092a0
---> c9290332f486
Step 4/10 : ADD packages/apr-${apr_version}.tar.gz /usr/src
---> 24cf195ba344
Step 5/10 : ADD packages/apr-util-${apr_util_version}.tar.gz /usr/src
---> bd95e78a3004
Step 6/10 : ADD packages/httpd-${httpd_version}.tar.gz /usr/src
---> e421bcc0ffc1
Step 7/10 : 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 --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
---> Running in 02ef027c7ded
CentOS Linux 8 - AppStream 80 B/s | 38 B 00:00
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist