1、安装步骤
1.1、确定Linux虚拟机的版本
cat /etc/redhat-release
1.2、卸载旧的版本
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
1.3、安装docker环境要求
yum -y install gcc
yum -y install gcc-c++
1.4、安装docker需要的软件包
yum install -y yum-utils
1.5、设置stable镜像仓库
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
1.6、更新yum软件包索引
yum makecache fast
1.7、安装docker ce
yum -y install docker-ce docker-ce-cli containerd.io
1.8、启动docker
systemctl start docker
1.9、测试
docker version
docker run hello-world
1.10、卸载
systemctl stop docker
yum remove docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker
rm -rf /var/lib/containerd
2、阿里云镜像加速
2.1、访问网站
阿里云镜像访问网站
2.2、粘贴脚本并运行
mkdir -p /etc/docker
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://{自已的编码}.mirror.aliyuncs.com"]
}
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://{自已的编码}.mirror.aliyuncs.com"]
}
EOF
2.3、重启服务器
systemctl daemon-reload
systemctl restart docker