Linux Centos7 安装 docker(极速安装)

1. 卸载旧版本

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

3.1 近期发现Centos8会报错,错误如下

非Centos8略过

Error: 
 Problem: package docker-ce-3:19.03.9-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed

解决办法:

#下载 containerd
[root@ebs-55853 down]# wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.13-3.1.el7.x86_64.rpm

#安装 containerd
[root@ebs-55853 down]# yum -y install ./containerd.io-1.2.13-3.1.el7.x86_64.rpm

4. 搜索docker版本

yum list docker-ce --showduplicates | sort -r

查找结果为:

[root@ebs-55853 down]# yum list docker-ce --showduplicates | sort -r
 * updates: mirror.lzu.edu.cn
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
Installed Packages
 * extras: mirror.lzu.edu.cn
docker-ce.x86_64            3:19.03.5-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:19.03.5-3.el7                    @docker-ce-stable
docker-ce.x86_64            3:19.03.4-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:19.03.3-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:19.03.2-3.el7                    docker-ce-stable

5. 通过查找到的版本,使用下面命令进行安装。

#yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
#<VERSION_STRING> 替换为查找到需要安装的版本号
#如上面最新版本是3:19.03.5-3.el7 ,那么命令行为
yum install docker-ce-19.03.5 docker-ce-cli-19.03.5 containerd.io

6. 安装完成,启动docker

systemctl start docker

7. 查看当前版本

docker -v

8. 设置开机启动

systemctl enable docker
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值