Centos快速安装Docke

时间:2020-11-19 20:01:00 来源:互联网 作者: 神秘的大神 字体:

预备
删除旧docker

# 删除旧docker
$ 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 \
    https://download.docker.com/linux/centos/docker-ce.repo
# 安装DOCKER引擎
$ sudo yum install docker-ce docker-ce-cli containerd.io

启动

# 启动
$ sudo systemctl start docker

设置开机自启

# 开机自启
sudo systemctl enable docker

镜像加速(这里在阿里云申请:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors)

# 创建/etc/docker/daemon.json文件
# 写入
{
  "registry-mirrors": ["https://XXXXXX.mirror.aliyuncs.com"]
}
# 刷新配置
sudo systemctl daemon-reload
# 重启docker
sudo systemctl restart docker