centos 安装 docker
- CentOS 7
- CentOS 8 (stream)
- CentOS 9 (stream)
卸载旧版本
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
添加docker的yum源
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
国内源
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum makecache fast
sudo yum -y install docker-ce
sudo service docker start
最新版
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
选版本安装
yum list docker-ce --showduplicates | sort -r
阿里云加速
登陆阿里云控制台查找你的加速地址
-
Start Docker.
$ sudo systemctl start docker
-
Verify that the Docker Engine installation is successful by running the
hello-world
image.$ sudo docker run hello-world