1.我用的是远程连接FinalShell远程连接软件,连接到VMware中的CenOS中
2.查看是否做好基础环境
vim /etc/selinux/config
看是否是SELINUX=disabled,如果不是,就改成disabled
关闭防火墙并查看是否关闭;清空本地规则;
systemctl stop firewalld
getenforce 0
iptables -F
3.安装阿里云镜像(安装过的就当更新)
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
4.清楚本地缓存生成新的缓存(出现“元数据缓存已建立”表示成功)
yum clean all && yum makecache
如果出现睡眠中的情况,断开连接,然后重启,重新执行yum clean all && yum makeacahe命令
reboot
如果重启了,再执行一次关闭防火墙的命令(getenforce stop firewalld),一定保证防火墙是关闭的。
5.基础做完后,我们开始配置网卡
cat <<EOF > /etc/sysctl.d/docker.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0
net.ipv4.ip_forward=1
EOF
把上面的全部复制到命令里,然后回车。
6.重新加载内核参数
sysctl -p /etc/sysctl.d/docker.conf
会报错,然后执行下面的命令
modprobe br_netfilter
然后再执行一次
7.下载阿里源repo文件(看好!!!这是两条命令分别执行)
curl -o /etc/yum.repos.d/Centos-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
8.更新yum 缓存(跟前面一样,出现“元数据缓存已建立”代表成功)
yum clean all && yum makecache
9.使用yum list 查看docker版本
yum list docker-ce --showduplicates | sort -r
10.我们安装20.10.6这个版本(这个要等一小会儿)
yum install docker-ce-20.10.6 -y
11.安装完毕后,配置docker加速器,加速镜像文件的下载
创建目录,配置加速器:
mkdir -p /etc/docker
vim /etc/docker/daemon.json
{
"registry-mirrors" : [
"https://8xpk5wnt.mirror.aliyuncs.com"
]
}
把这个复制到文件中,全部复制,少一个就配置不成功。要出现这种颜色。
12.重启,设置开机自启
systemctl enable docker
systemctl daemon-reload
systemctl restart docker
13.查看版本
docker version
到这里docker就安装完成了。