其他分享
首页 > 其他分享> > 用podman进行dockerfile做一个httpd编译安装的镜像

用podman进行dockerfile做一个httpd编译安装的镜像

作者:互联网

用podman进行dockerfile做一个httpd编译安装的镜像

目录

1.创建好目录结构

#下载好需要使用的包
[root@localhost ~]# wget http://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz https://mirrors.aliyun.com/apache/httpd/httpd-2.4.54.tar.gz

#创建好一个目录存放包和dockerfile
[root@localhost apache]# mkdir bao
[root@localhost apache]# touch Dockerfile
[root@localhost apache]# cd
[root@localhost ~]# mv *.tar.gz apache/bao/
[root@localhost ~]# tree apache/
apache/
|-- Dockerfile
`-- bao
    |-- apr-1.7.0.tar.gz
    |-- apr-util-1.6.1.tar.gz
    `-- httpd-2.4.54.tar.gz

2.进行编写dockerfile

[root@localhost ~]# cd apache/
[root@localhost apache]# vim Dockerfile 
[root@localhost apache]# cat Dockerfile
FROM centos				//指定使用镜像

LABEL MAINTAINER "zxr 2428341246@qq.com"		//作者信息

ENV apr_version=1.7.0 apr_util_version=1.6.1 httpd_version=2.4.54	//版本号变量

ADD bao/* /usr/src/		//使用add会自动解压

RUN rm -rf /etc/yum.repo.d/* && \
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo && \
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-rpm=prefork

WORKDIR /usr/local/apache			//工作目录

EXPOSE 80		//暴露端口号

CMD ["-D","FOREGROUND"]			//启动

ENTRYPOINT /usr/local/apache/bin/apachectl -DFOREGROUND		//用说明启动

3.使用dockerfile创建镜像

[root@localhost ~]# podman build -t xinruizhong/httpd:v0.1 apache/

4.使用镜像运行容器进行测试

[root@localhost ~]# podman run -it --name web -p 80:80 xinruizhong/httpd:v0.1
e4af98410c7aa696bd6fac3a73e3ab21e981271798a9fd1f8421354afdeba702

image

5.将镜像上传

[root@localhost ~]# podman login
Username: xinruizhong
Password: 
Login Succeeded!
[root@localhost ~]# podman push xinruizhong/httpd:v0.1
Getting image source signatures
Copying blob 273a2c5e560e done  
Copying blob 2653d992f4ef done  
Copying blob b10d9acabeb0 done  
Copying config 98fe321319 done  
Writing manifest to image destination
Storing signatures

image

标签:httpd,podman,--,root,apr,&&,apache,dockerfile,localhost
来源: https://www.cnblogs.com/Their-own/p/16636806.html