dockerfile基于centos源码制作httpd镜像v2
创建目录
[root@localhost dockerfile-httpd]# tree
.
├── Dockerfile
├── httpd
│ ├── apr-1.6.5.tar.gz
│ ├── apr-util-1.6.1.tar.gz
│ └── httpd-2.4.54.tar.bz2
└── scripts
└── entrypoint.sh
脚本
[root@localhost dockerfile-httpd]# cat scripts/entrypoint.sh
#!/bin/bash
sed -i '/#ServerName/s/#//g' /usr/local/apache/conf/httpd.conf
exec "$@"
//添加执行权限
[root@localhost dockerfile-httpd]# chmod +x scripts/entrypoint.sh
dockerfile
[root@localhost dockerfile-httpd]# vi Dockerfile
FROM centos
LABEL MAINTAINER='wenjincheng 2535636586@qq.com'
ENV apr_version=1.6.5 apr_util_version=1.6.1 httpd_version=2.4.54
ENV PATH /usr/local/apache/bin:$PATH
ADD packages/httpd-${httpd_version}.tar.gz /usr/src
ADD packages/apr-${apr_version}.tar.gz /usr/src
ADD packages/apr-util-${apr_util_version}.tar.gz /usr/src
ADD scripts/entrypoint.sh /
RUN rm -f /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 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 && \
yum clean all && \
yum -y remove gcc gcc-gcc+ make && \
rm -rf /tmp/* /usr/src/*
WORKDIR /usr/local/apache
EXPOSE 80
CMD ["httpd","-D","FOREGROUND"]
ENTRYPOINT ["/bin/bash","/entrypoint.sh"]
创建镜像
[root@localhost httpd]# podman build -t httpd:v1.2 .
上传
[root@10 httpd]# podman tag httpd:v1.2 docker.io/raylight2002/httpd:v1.2
[root@10 httpd]# podman login docker.io
Username: raylight2002
Password:
Login Succeeded!
[root@10 httpd]# podman push docker.io/raylight2002/httpd:v1.2
Getting image source signatures
Copying blob 797a97584c31 done
Copying blob b2bac86c42de done
Copying blob 3754c0c56c35 done
Copying blob 2653d992f4ef done
Copying blob 10631f5c60b7 done
Copying blob 86097abb0ff3 done
Copying config 1570966a32 done
Writing manifest to image destination
Storing signatures