环境查看
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
安装
官网:https://docs.docker.com/engine/install/centos/
帮助文档:
#卸载旧的版本
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
#设置镜像仓库阿里云或者华为云
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#sudo yum-config-manager --add-repo https://mirrors.huaweicloud.com/repository/conf/CentOS-7-reg.repo
#更新软件包索引
yum makecache fast
#安装最新的docker引擎 cc社区版
sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
#配置华为云镜像加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxxxxxxxxxxf9f4a.mirror.swr.myhuaweicloud.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
#启动docker
systemctl start docker
#检查是否启动成功
docker version
#docker开机自启动
systemctl enable docker.service
获取华为云镜像地址