如果之前安装过docker需要删除之前的。
sudo dnf -y remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
安装yum-utils工具:
dnf -y install yum-utils dnf-plugins-core
设置存储库:添加国内阿里docker镜像源
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
docker官网存储库
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
docker由于在国外以及国家方面的一些情况导致并没有开放docker官网的。建议使用阿里云。
安装docker软件包
sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
添加docker镜像
cat >/etc/docker/daemon.json<< jingyu
{"registry-mirrors": ["https://docker.1ms.run","https://doublezonline.cloud","https://dislabaiot.xyz","https://docker.fxxk.dedyn.io","https://dockerpull.org","https://docker.unsee.tech","https://hub.rat.dev","https://docker.1panel.live","https://docker.nastool.de","https://docker.zhai.cm","https://docker.5z5f.com","https://a.ussh.net","https://docker.udayun.com","https://hub.geekery.cn"]
}
jingyu
启动docker engine
sudo systemctl enable --now docker
通过运行映像来验证安装是否成功:hello-world
sudo docker run hello-world