在CentOS 7.9上安装Docker通常涉及以下步骤:
-
卸载旧版本的Docker(如果有):
sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
-
安装所需的依赖包:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
-
设置Docker的仓库:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
-
安装Docker Engine - Community:
sudo yum install docker-ce docker-ce-cli containerd.io
-
启动Docker服务:
sudo systemctl start docker
-
设置Docker服务开机自启:
sudo systemctl enable docker
-
验证Docker是否安装成功:
sudo docker run hello-world