1.卸載可能存在的舊版docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
2.添加docker資源庫
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
3.安裝docker
sudo yum install docker-ce docker-ce-cli containerd.io
可能遇到的問題:
Problem: package docker-ce-3:19.03.12-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
需要自行下載安裝高版本containerd.io
wget https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/edge/Packages/containerd.io-1.2.13-3.2.el7.x86_64.rpm
sudo yum install containerd.io-1.2.13-3.2.el7.x86_64.rpm
重新執(zhí)行安裝命令
這里可能還會遇到問題:
Error:Transaction test error:
file /usr/share/man/man1/docker-attach.1.gz from install of docker-ce-cli-1:19.03.12-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
這是因為CentOS8中自帶的容器軟件podman與docker沖突,如需繼續(xù)安裝,卸載即可
yum remove podman
重新執(zhí)行安裝命令
安裝完成
4.docker啟動并設置為開機啟動
sudo systemctl start docker
sudo systemctl enable docker