基于容器的方式做一个apache编译安装的镜像
目录
创建容器前的部署
[root@localhost ~]# docker search centos //查询centos镜像
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
centos The official build of CentOS. 7275 [OK]
kasmweb/centos-7-desktop CentOS 7 desktop for Kasm Workspaces 23
continuumio/centos5_gcc5_base 3
dokken/centos-7 CentOS 7 image for kitchen-dokken 3
dokken/centos-stream-9 2
couchbase/centos7-systemd centos7-systemd images with additional debug… 2 [OK]
dokken/centos-stream-8 2
spack/centos7 CentOS 7 with Spack preinstalled 1
spack/centos6 CentOS 6 with Spack preinstalled 1
dokken/centos-8 CentOS 8 image for kitchen-dokken 0
dokken/centos-6 CentOS 6 image for kitchen-dokken 0
ustclug/centos Official CentOS Image with USTC Mirror 0
bitnami/centos-extras-base 0
corpusops/centos-bare https://github.com/corpusops/docker-images/ 0
datadog/centos-i386 0
corpusops/centos centos corpusops baseimage 0
couchbase/centos-72-java-sdk 0
couchbase/centos-72-jenkins-core 0
bitnami/centos-base-buildpack Centos base compilation image 0 [OK]
couchbase/centos-69-sdk-nodevtoolset-build 0
fnndsc/centos-python3 Source for a slim Centos-based Python3 image… 0 [OK]
couchbase/centos-69-sdk-build 0
couchbase/centos-70-sdk-build 0
dokken/centos-5 EOL DISTRO: For use with kitchen-dokken, Bas… 0
spack/centos-stream 0
[root@localhost ~]# docker pull centos //拉取最新版镜像
Using default tag: latest
latest: Pulling from library/centos
a1d0c7532777: Pull complete
Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest
[root@localhost ~]# docker images //列出镜像
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 5d0da3dc9764 10 months ago 231MB
[root@localhost ~]# docker run -it --name b1 centos /bin/bash
//启动容器
[root@3e493c00a7f0 /]# cd
[root@3e493c00a7f0 ~]# cd /etc/yum.repos.d/
[root@3e493c00a7f0 yum.repos.d]# ls
CentOS-Linux-AppStream.repo CentOS-Linux-FastTrack.repo
CentOS-Linux-BaseOS.repo CentOS-Linux-HighAvailability.repo
CentOS-Linux-ContinuousRelease.repo CentOS-Linux-Media.repo
CentOS-Linux-Debuginfo.repo CentOS-Linux-Plus.repo
CentOS-Linux-Devel.repo CentOS-Linux-PowerTools.repo
CentOS-Linux-Extras.repo CentOS-Linux-Sources.repo
[root@3e493c00a7f0 yum.repos.d]# rm -rf *
//删除原来的源(在国外,下载东西比较慢),准备安装阿里源
[root@3e493c00a7f0 yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2495 100 2495 0 0 7231 0 --:--:-- --:--:-- --:--:-- 7210
[root@3e493c00a7f0 yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
//下载阿里源(阿里云官方网站上面有)
[root@3e493c00a7f0 yum.repos.d]# ls
CentOS-Base.repo
[root@3e493c00a7f0 yum.repos.d]# dnf clean all //清理缓存
Failed to set locale, defaulting to C.UTF-8
0 files removed
[root@3e493c00a7f0 yum.repos.d]# dnf makecache
//创建缓存
[root@3e493c00a7f0 yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
[root@3e493c0