dockerfile构建apache
//目录树
[root@localhost apache]# tree
.
├── Dockerfile
└── packages
├── apr-1.7.0.tar.gz
├── apr-util-1.6.1.tar.gz
└── httpd-2.4.49.tar.gz
1 directory, 4 files
//dockerfile
[root@localhost apache]# cat Dockerfile
FROM centos
LABEL MAINTAINER='abc 1@2.com'
ENV httpd_version 2.4.49
ENV PATH /usr/local/apache/bin:$PATH
ADD files/apr-1.7.0.tar.gz files/apr-util-1.6.1.tar.gz files/httpd-${httpd_version}.tar.gz /usr/src/
RUN rm -f /etc/yum.repos.d/* &&
curl -o /etc/yum.repos.d/CentOS-base.repo https://mirrors.aliyun.com/repo/Centos-$(awk -F'[ .]+' '{print $4}' /etc/redhat-release).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 epel-release openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make libxml2-devel &&
yum groups mark install 'Development Tools' -y &&
useradd -r -M -s /sbin/nologin apache &&
cd /usr/src/apr-1.7.0 &&
sed -i '/$RM "$cfgfile"/d' configure &&
./configure --prefix=/usr/local/apr && make && make install &&
cd ../apr-util-1.6.1 &&
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr &&
make && make install &&
cd ../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 -j $(nproc) && make install &&
sed -i '/#ServerName/s/#//g' /usr/local/apache/conf/httpd.conf &&
yum -y remove gcc gcc-c++ make &&
rm -rf /var/cache/* &&
rm -rf /usr/src/*
WORKDIR /usr/local/apache
EXPOSE 80 443
CMD ["-D","FOREGROUND"]
ENTRYPOINT ["apachectl"]
//构建镜像
[root@localhost ~]# docker build -t wyus/httpd:v0.2 apache/
//查看镜像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
wyus/httpd v0.2 91e16b01854d 58 seconds ago 744MB