Dockerfile + 源码安装httpd 制作镜像
环境:
虚拟机版本 | ip | 部署应用 |
---|---|---|
centos8 | 192.168.136.142 | docker |
[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 ~]#