Docker安装参考:https://developer.aliyun.com/article/110806
shell
# 1、卸载之前的docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
# 2、安装必要的依赖
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
# 3、添加软件源信息
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 4、更新并安装 Docker-CE
sudo yum makecache fast
sudo yum -y install docker-ce
# 5、开启Docker服务
sudo service docker start
shell
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://q216dh9c.mirror.aliyuncs.com"]
}
EOF
# 这里有个坑,需要先分别停掉 docker.service 和 docker.socket,然后再重启,否则可能配置不会生效(还是从官方镜像源拉取)
sudo systemctl stop docker.service
sudo systemctl stop docker.socket
sudo systemctl start docker.service
sudo systemctl start docker.socket
sudo systemctl daemon-reload
sudo systemctl restart docker