Centos7 安装 docker

Centos7 安装 docker

1.更新yum版本
$ sudo yum update
2、卸载旧版本(如果安装过旧版本的话)
[root@localhost jzj]# sudo yum remove docker  docker-common docker-selinux docker-engine
已加载插件:fastestmirror
参数 docker 没有匹配
参数 docker-common 没有匹配
参数 docker-selinux 没有匹配
参数 docker-engine 没有匹配
不删除任何软件包

3、加载插件

安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的

[root@localhost jzj]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
base                                                            | 3.6 kB  00:00:00     
extras                                                          | 2.9 kB  00:00:00     
updates                                                         | 2.9 kB  00:00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 device-mapper-persistent-data.x86_64.0.0.8.5-3.el7 将被 升级
---> 软件包 device-mapper-persistent-data.x86_64.0.0.8.5-3.el7_9.2 将被 更新

------------
** 发现 2 个已存在的 RPM 数据库问题, 'yum check' 输出如下:
PackageKit-1.1.10-2.el7.centos.x86_64 有缺少的需求 PackageKit-backend
anaconda-core-21.48.22.159-1.el7.centos.x86_64 有缺少的需求 yum-utils >= ('0', '1.1.11', '3')
  正在更新    : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64                    1/15 
  验证中      : 7:device-mapper-1.02.170-6.el7.x86_64                            15/15 

已安装:
  yum-utils.noarch 0:1.1.31-54.el7_8                                                   

更新完毕:
  device-mapper-persistent-data.x86_64 0:0.8.5-3.el7_9.2                               
  lvm2.x86_64 7:2.02.187-6.el7_9.5                                                     

作为依赖被升级:
  device-mapper.x86_64 7:1.02.170-6.el7_9.5                                            
  device-mapper-event.x86_64 7:1.02.170-6.el7_9.5                                      
  device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5                                 
  device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5                                       
  lvm2-libs.x86_64 7:2.02.187-6.el7_9.5                                                

完毕!

4、设置yum源
[root@localhost jzj]# sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
已加载插件:fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

5.可以查看所有仓库中所有docker版本,并选择版本安装
[root@localhost jzj]# yum list docker-ce --showduplicates | sort -r
已加载插件:fastestmirror
可安装的软件包
Loading mirror speeds from cached hostfile
docker-ce.x86_64            3:20.10.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:20.10.1-3.el7                     docker-ce-stable

6、安装docker

我这里选择最新的稳定版本,中间需要输入是否继续:Y

oot@localhost jzj]# sudo yum install docker-ce
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.3.20.10.7-3.el7 将被 安装
--> 正在处理依赖关系 container-selinux >= 2:2.74,它被软件包 3:docker-ce-20.10.7-3.el7.x86_64 需要

==============================================================================================================================
 Package                             架构             版本                                   源                          大小
==============================================================================================================================
正在安装:
 docker-ce                           x86_64           3:20.10.7-3.el7                        docker-ce-stable            27 M
为依赖而安装:
 container-selinux                   noarch           2:2.119.2-1.911c772.el7_8              extras                      40 k
 containerd.io                       x86_64           1.4.6-3.1.el7                          docker-ce-stable            34 M
 docker-ce-cli                       x86_64           1:20.10.7-3.el7                        docker-ce-stable            33 M
 docker-ce-rootless-extras           x86_64           20.10.7-3.el7                          docker-ce-stable           9.2 M
 docker-scan-plugin                  x86_64           0.8.0-3.el7                            docker-ce-stable           4.2 M
 fuse-overlayfs                      x86_64           0.7.2-6.el7_8                          extras                      54 k
 fuse3-libs                          x86_64           3.6.1-4.el7                            extras                      82 k
 slirp4netns                         x86_64           0.4.3-4.el7_8                          extras                      81 k

事务概要
==============================================================================================================================
安装  1 软件包 (+8 依赖软件包)

总下载量:107 M
安装大小:438 M

已安装:
  docker-ce.x86_64 3:20.10.7-3.el7                                                                                            

作为依赖被安装:
  container-selinux.noarch 2:2.119.2-1.911c772.el7_8             containerd.io.x86_64 0:1.4.6-3.1.el7                        
  docker-ce-cli.x86_64 1:20.10.7-3.el7                           docker-ce-rootless-extras.x86_64 0:20.10.7-3.el7            
  docker-scan-plugin.x86_64 0:0.8.0-3.el7                        fuse-overlayfs.x86_64 0:0.7.2-6.el7_8                       
  fuse3-libs.x86_64 0:3.6.1-4.el7                                slirp4netns.x86_64 0:0.4.3-4.el7_8                          

完毕!
7、也可以尝试指定版本安装
[root@localhost jzj]# sudo yum install 3:20.10.7-3.el7
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
没有可用软件包 3:20.10.7-3.el7。
错误:无须任何处理
8、启动并加入开机启动
[root@localhost jzj]# sudo systemctl start docker
[root@localhost jzj]# sudo systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

9、验证安装是否成功(有client和service两部分表示docker安装启动都成功了)

查看版本 docker version

[root@localhost jzj]# docker version
Client: Docker Engine - Community
 Version:           20.10.7
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        f0df350
 Built:             Wed Jun  2 11:58:10 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.7
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       b0f5bc3
  Built:            Wed Jun  2 11:56:35 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.6
  GitCommit:        d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc:
  Version:          1.0.0-rc95
  GitCommit:        b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
[root@localhost jzj]# 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值