CentOS7模板机搭建

一、更新Yum源

1.1 备份

1
2
3
cd /etc/yum.repos.d/
mkdir back
mv *.repo back/

1.2 下载并上传新的repo文件

1
2
下载地址:https://mirrors.aliyun.com/repo/Centos-7.repo
下载地址:https://mirrors.aliyun.com/repo/epel-7.repo

1.3 运行 yum makecache 生成缓存

1
yum makecache

1.4 更新软件

1
yum update -y

二、安装wget

1
yum install wget -y

三、安装net-tools

1
yum install -y net-tools

四、安装vim

1
yum install -y vim

五、关闭防火墙

1
2
systemctl stop firewalld
systemctl disable firewalld

六、关闭SeLinux

1
vim /etc/selinux/config

七、安装Docker

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 1、yum 包更新到最新 
yum update
# 2、安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的
yum install -y yum-utils device-mapper-persistent-data lvm2
# 3、设置yum源
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 4、安装docker,出现输入的界面都按 y
yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# 5、查看docker版本,验证是否验证成功
docker -v
# 6、设置开机自启
systemctl enable docker
# 7、配置镜像
mkdir -p /etc/docker
cd /etc/docker
vim daemon.json
# 8、更新配置
systemctl daemon-reload
systemctl restart docker
1
2
3
4
5
6
{
"registry-mirrors": [
"https://docker.1ms.run",
"https://docker.xuanyuan.me"
]
}

八、备注

1
目前已按照上述流程创建了一个模板虚拟机,为了方便后续下载使用,因此已存放在阿里云盘中