CentOS7和8安装Docker

CentOS安装Docker

CentOS8上安装Docker和CentOS7上安装步骤不太一样,有点儿小坑,网上参考了一些前辈的博客之后,实验了一下,成功填坑,就把具体步骤记录了下来,在这里也顺便把之前CentOS7上安装Docker的步骤分享一下。

1. CentOS7安装Docker

安装步骤
uname -r 3.10.0-327.el7.x86_64
yum install -y yum-utils device-mapper-persistent-data lvm2
yum remove docker
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
yum makecache fast
yum -y install docker-ce
systemctl start docker
docker run hello-world
国内镜像加速
  1. https://registry.docker-cn.com
  2. http://hub-mirror.c.163.com
  3. https://3laho3y3.mirror.aliyuncs.com
  4. http://f1361db2.m.daocloud.io
  5. https://mirror.ccs.tencentyun.com
镜像加速
# 新版的Docker 使用/etc/docker/daemon.json(Linux) 
# 或者 %programdata%\docker\config\daemon.json(Windows) 来配置 Daemon。
# 请在该配置文件中加入(没有该文件的话,请先建一个):

vim /etc/docker/daemon.json
{
  "registry-mirrors": ["https://registry.docker-cn.com"]
}
systemctl daemon-reload
systemctl restart docker
删除 Docker CE
    yum remove docker-ce
    rm -rf /var/lib/docke

2. CentOS8安装Docker

卸载旧版docker
yum -y  remove docker  docker-common docker-selinux docker-engine
设置yum源
yum-config-manager  --add-repo  http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo #阿里云yum源
安装新版的containerd.io软件包
wget https://download.docker.com/linux/centos/7/x86_64/edge/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
yum -y install containerd.io-1.2.6-3.3.el7.x86_64.rpm 
安装完成后重新安装Docker
yum -y install docker-ce
systemctl start docker
systemctl enable docker
配置阿里云镜像加速
mkdir  -p  /etc/docker
vi  /etc/docker/daemon.json
{"registry-mirrors": 
["https://5f2jam6c.mirror.aliyuncs.com", 
"http://hub-mirror.c.163.com"]
}
systemctl reload  docker
systemctl restart docker

你可能感兴趣的:(Linux)