zoukankan      html  css  js  c++  java
  • Docker-centos7学习安装Docker

    一、DOCKER安装命令

    方法1:

    使用官方安装脚本自动安装
    安装命令如下:
    
    curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

    方法2:

    也可以使用国内 daocloud 一键安装命令:
    
    curl -sSL https://get.daocloud.io/docker | sh

    方法3:

    yum install -y yum-utils device-mapper-persistent-data lvm2
    yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    yum install docker-ce
    systemctl start docker

    二、操作流程

    1.查看下自己centos的版本

    centos:7.6-1810

    内核:3.10.0-957.el7x86_64

    2.检查是否安装过docker

    可以看到,我安装过DOCKER,现在要卸载

    3.卸载Docker

    卸载旧版本
    较旧的 Docker 版本称为 docker 或 docker-engine 。如果已安装这些程序,请卸载它们以及相关的依赖项。
    
    $ sudo yum remove docker 
                      docker-client 
                      docker-client-latest 
                      docker-common 
                      docker-latest 
                      docker-latest-logrotate 
                      docker-logrotate 
                      docker-engine

    4.安装Docker及依赖

    yum install -y yum-utils device-mapper-persistent-data lvm2

    [root@jumpserver ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
    已加载插件:fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
     * base: mirrors.aliyun.com
     * extras: mirrors.aliyun.com
     * updates: mirrors.aliyun.com
    http://nginx.org/packages/centos/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to 2a05:d014:edb:5704::6: 网络不可达"
    正在尝试其它镜像。
    http://nginx.org/packages/centos/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to 2a05:d014:edb:5704::6: 网络不可达"
    正在尝试其它镜像。
    http://nginx.org/packages/centos/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to 2a05:d014:edb:5704::6: 网络不可达"
    正在尝试其它镜像。
    http://nginx.org/packages/centos/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to 2a05:d014:edb:5704::6: 网络不可达"
    正在尝试其它镜像。
    http://nginx.org/packages/centos/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to 2a05:d014:edb:5704::6: 网络不可达"
    正在尝试其它镜像。
    http://nginx.org/packages/centos/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to 2a05:d014:edb:5704::6: 网络不可达"
    正在尝试其它镜像。
    http://nginx.org/packages/centos/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to 2a05:d014:edb:5704::6: 网络不可达"
    正在尝试其它镜像。
    http://nginx.org/packages/centos/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to 2a05:d014:edb:5704::6: 网络不可达"
    正在尝试其它镜像。
    http://nginx.org/packages/centos/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to 2a05:d014:edb:5704::6: 网络不可达"
    正在尝试其它镜像。
    http://nginx.org/packages/centos/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to 2a05:d014:edb:5704::6: 网络不可达"
    正在尝试其它镜像。
    正在解决依赖关系
    --> 正在检查事务
    ---> 软件包 device-mapper-persistent-data.x86_64.0.0.8.5-1.el7 将被 升级
    ---> 软件包 device-mapper-persistent-data.x86_64.0.0.8.5-3.el7_9.2 将被 更新
    ---> 软件包 lvm2.x86_64.7.2.02.185-2.el7_7.2 将被 升级
    ---> 软件包 lvm2.x86_64.7.2.02.187-6.el7_9.5 将被 更新
    --> 正在处理依赖关系 lvm2-libs = 7:2.02.187-6.el7_9.5,它被软件包 7:lvm2-2.02.187-6.el7_9.5.x86_64 需要
    ---> 软件包 yum-utils.noarch.0.1.1.31-52.el7 将被 升级
    ---> 软件包 yum-utils.noarch.0.1.1.31-54.el7_8 将被 更新
    --> 正在检查事务
    ---> 软件包 lvm2-libs.x86_64.7.2.02.185-2.el7_7.2 将被 升级
    ---> 软件包 lvm2-libs.x86_64.7.2.02.187-6.el7_9.5 将被 更新
    --> 正在处理依赖关系 device-mapper-event = 7:1.02.170-6.el7_9.5,它被软件包 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64 需要
    --> 正在检查事务
    ---> 软件包 device-mapper-event.x86_64.7.1.02.158-2.el7_7.2 将被 升级
    ---> 软件包 device-mapper-event.x86_64.7.1.02.170-6.el7_9.5 将被 更新
    --> 正在处理依赖关系 device-mapper-event-libs = 7:1.02.170-6.el7_9.5,它被软件包 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64 需要
    --> 正在处理依赖关系 device-mapper = 7:1.02.170-6.el7_9.5,它被软件包 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64 需要
    --> 正在检查事务
    ---> 软件包 device-mapper.x86_64.7.1.02.158-2.el7_7.2 将被 升级
    --> 正在处理依赖关系 device-mapper = 7:1.02.158-2.el7_7.2,它被软件包 7:device-mapper-libs-1.02.158-2.el7_7.2.x86_64 需要
    ---> 软件包 device-mapper.x86_64.7.1.02.170-6.el7_9.5 将被 更新
    ---> 软件包 device-mapper-event-libs.x86_64.7.1.02.158-2.el7_7.2 将被 升级
    ---> 软件包 device-mapper-event-libs.x86_64.7.1.02.170-6.el7_9.5 将被 更新
    --> 正在检查事务
    ---> 软件包 device-mapper-libs.x86_64.7.1.02.158-2.el7_7.2 将被 升级
    ---> 软件包 device-mapper-libs.x86_64.7.1.02.170-6.el7_9.5 将被 更新
    --> 解决依赖关系完成
    
    依赖关系解决
    
    ===================================================================================================================================================================
     Package                                             架构                         版本                                         源                             大小
    ===================================================================================================================================================================
    正在更新:
     device-mapper-persistent-data                       x86_64                       0.8.5-3.el7_9.2                              updates                       423 k
     lvm2                                                x86_64                       7:2.02.187-6.el7_9.5                         updates                       1.3 M
     yum-utils                                           noarch                       1.1.31-54.el7_8                              base                          122 k
    为依赖而更新:
     device-mapper                                       x86_64                       7:1.02.170-6.el7_9.5                         updates                       297 k
     device-mapper-event                                 x86_64                       7:1.02.170-6.el7_9.5                         updates                       192 k
     device-mapper-event-libs                            x86_64                       7:1.02.170-6.el7_9.5                         updates                       192 k
     device-mapper-libs                                  x86_64                       7:1.02.170-6.el7_9.5                         updates                       325 k
     lvm2-libs                                           x86_64                       7:2.02.187-6.el7_9.5                         updates                       1.1 M
    
    事务概要
    ===================================================================================================================================================================
    升级  3 软件包 (+5 依赖软件包)
    
    总计:3.9 M
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      正在更新    : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64                                                                                                1/16 
      正在更新    : 7:device-mapper-1.02.170-6.el7_9.5.x86_64                                                                                                     2/16 
      正在更新    : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64                                                                                          3/16 
      正在更新    : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64                                                                                               4/16 
      正在更新    : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64                                                                                                         5/16 
      正在更新    : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64                                                                                          6/16 
      正在更新    : 7:lvm2-2.02.187-6.el7_9.5.x86_64                                                                                                              7/16 
      正在更新    : yum-utils-1.1.31-54.el7_8.noarch                                                                                                              8/16 
      清理        : 7:lvm2-2.02.185-2.el7_7.2.x86_64                                                                                                              9/16 
      清理        : yum-utils-1.1.31-52.el7.noarch                                                                                                               10/16 
      清理        : 7:lvm2-libs-2.02.185-2.el7_7.2.x86_64                                                                                                        11/16 
      清理        : 7:device-mapper-event-1.02.158-2.el7_7.2.x86_64                                                                                              12/16 
      清理        : 7:device-mapper-event-libs-1.02.158-2.el7_7.2.x86_64                                                                                         13/16 
      清理        : 7:device-mapper-1.02.158-2.el7_7.2.x86_64                                                                                                    14/16 
      清理        : 7:device-mapper-libs-1.02.158-2.el7_7.2.x86_64                                                                                               15/16 
      清理        : device-mapper-persistent-data-0.8.5-1.el7.x86_64                                                                                             16/16 
      验证中      : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64                                                                                               1/16 
      验证中      : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64                                                                                          2/16 
      验证中      : 7:device-mapper-1.02.170-6.el7_9.5.x86_64                                                                                                     3/16 
      验证中      : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64                                                                                                4/16 
      验证中      : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64                                                                                                         5/16 
      验证中      : 7:lvm2-2.02.187-6.el7_9.5.x86_64                                                                                                              6/16 
      验证中      : yum-utils-1.1.31-54.el7_8.noarch                                                                                                              7/16 
      验证中      : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64                                                                                          8/16 
      验证中      : 7:device-mapper-1.02.158-2.el7_7.2.x86_64                                                                                                     9/16 
      验证中      : yum-utils-1.1.31-52.el7.noarch                                                                                                               10/16 
      验证中      : device-mapper-persistent-data-0.8.5-1.el7.x86_64                                                                                             11/16 
      验证中      : 7:lvm2-2.02.185-2.el7_7.2.x86_64                                                                                                             12/16 
      验证中      : 7:device-mapper-libs-1.02.158-2.el7_7.2.x86_64                                                                                               13/16 
      验证中      : 7:lvm2-libs-2.02.185-2.el7_7.2.x86_64                                                                                                        14/16 
      验证中      : 7:device-mapper-event-1.02.158-2.el7_7.2.x86_64                                                                                              15/16 
      验证中      : 7:device-mapper-event-libs-1.02.158-2.el7_7.2.x86_64                                                                                         16/16 
    
    更新完毕:
      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              yum-utils.noarch 0:1.1.31-54.el7_8             
    
    作为依赖被升级:
      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              
    
    完毕!
    [root@jumpserver ~]# 

    5.设置yum源

    官方:yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    
    
    或者阿里云
    $ sudo yum-config-manager 
        --add-repo 
        http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    或者清华大学源
    $ sudo yum-config-manager 
        --add-repo 
        https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo

    我安装清华大学的

    6.安装docker

     
    [root@jumpserver ~]# yum install -y docker-ce
    已加载插件:fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
     * base: mirrors.aliyun.com
     * extras: mirrors.aliyun.com
     * updates: mirrors.aliyun.com
    正在解决依赖关系
    --> 正在检查事务
    ---> 软件包 docker-ce.x86_64.3.20.10.10-3.el7 将被 安装
    --> 正在处理依赖关系 containerd.io >= 1.4.1,它被软件包 3:docker-ce-20.10.10-3.el7.x86_64 需要
    --> 正在处理依赖关系 docker-ce-cli,它被软件包 3:docker-ce-20.10.10-3.el7.x86_64 需要
    --> 正在处理依赖关系 docker-ce-rootless-extras,它被软件包 3:docker-ce-20.10.10-3.el7.x86_64 需要
    --> 正在检查事务
    ---> 软件包 containerd.io.x86_64.0.1.2.13-3.1.el7 将被 升级
    ---> 软件包 containerd.io.x86_64.0.1.4.11-3.1.el7 将被 更新
    ---> 软件包 docker-ce-cli.x86_64.1.20.10.10-3.el7 将被 安装
    --> 正在处理依赖关系 docker-scan-plugin(x86-64),它被软件包 1:docker-ce-cli-20.10.10-3.el7.x86_64 需要
    ---> 软件包 docker-ce-rootless-extras.x86_64.0.20.10.10-3.el7 将被 安装
    --> 正在处理依赖关系 fuse-overlayfs >= 0.7,它被软件包 docker-ce-rootless-extras-20.10.10-3.el7.x86_64 需要
    --> 正在处理依赖关系 slirp4netns >= 0.4,它被软件包 docker-ce-rootless-extras-20.10.10-3.el7.x86_64 需要
    --> 正在检查事务
    ---> 软件包 docker-scan-plugin.x86_64.0.0.9.0-3.el7 将被 安装
    ---> 软件包 fuse-overlayfs.x86_64.0.0.7.2-6.el7_8 将被 安装
    --> 正在处理依赖关系 libfuse3.so.3(FUSE_3.2)(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
    --> 正在处理依赖关系 libfuse3.so.3(FUSE_3.0)(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
    --> 正在处理依赖关系 libfuse3.so.3()(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
    ---> 软件包 slirp4netns.x86_64.0.0.4.3-4.el7_8 将被 安装
    --> 正在检查事务
    ---> 软件包 fuse3-libs.x86_64.0.3.6.1-4.el7 将被 安装
    --> 解决依赖关系完成
    
    依赖关系解决
    
    ===================================================================================================================================================================
     Package                                         架构                         版本                                    源                                      大小
    ===================================================================================================================================================================
    正在安装:
     docker-ce                                       x86_64                       3:20.10.10-3.el7                        docker-ce-stable                        23 M
    为依赖而安装:
     docker-ce-cli                                   x86_64                       1:20.10.10-3.el7                        docker-ce-stable                        29 M
     docker-ce-rootless-extras                       x86_64                       20.10.10-3.el7                          docker-ce-stable                       8.0 M
     docker-scan-plugin                              x86_64                       0.9.0-3.el7                             docker-ce-stable                       3.7 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
    为依赖而更新:
     containerd.io                                   x86_64                       1.4.11-3.1.el7                          docker-ce-stable                        28 M
    
    事务概要
    ===================================================================================================================================================================
    安装  1 软件包 (+6 依赖软件包)
    升级           ( 1 依赖软件包)
    
    总计:92 M
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      正在安装    : 1:docker-ce-cli-20.10.10-3.el7.x86_64                                                                                                          1/9 
      正在安装    : docker-scan-plugin-0.9.0-3.el7.x86_64                                                                                                          2/9 
      正在安装    : fuse3-libs-3.6.1-4.el7.x86_64                                                                                                                  3/9 
      正在安装    : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                                                            4/9 
      正在安装    : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                                               5/9 
      正在更新    : containerd.io-1.4.11-3.1.el7.x86_64                                                                                                            6/9 
      正在安装    : 3:docker-ce-20.10.10-3.el7.x86_64                                                                                                              7/9 
      正在安装    : docker-ce-rootless-extras-20.10.10-3.el7.x86_64                                                                                                8/9 
      清理        : containerd.io-1.2.13-3.1.el7.x86_64                                                                                                            9/9 
      验证中      : docker-ce-rootless-extras-20.10.10-3.el7.x86_64                                                                                                1/9 
      验证中      : docker-scan-plugin-0.9.0-3.el7.x86_64                                                                                                          2/9 
      验证中      : 3:docker-ce-20.10.10-3.el7.x86_64                                                                                                              3/9 
      验证中      : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                                                                            4/9 
      验证中      : containerd.io-1.4.11-3.1.el7.x86_64                                                                                                            5/9 
      验证中      : slirp4netns-0.4.3-4.el7_8.x86_64                                                                                                               6/9 
      验证中      : fuse3-libs-3.6.1-4.el7.x86_64                                                                                                                  7/9 
      验证中      : 1:docker-ce-cli-20.10.10-3.el7.x86_64                                                                                                          8/9 
      验证中      : containerd.io-1.2.13-3.1.el7.x86_64                                                                                                            9/9 
    
    已安装:
      docker-ce.x86_64 3:20.10.10-3.el7                                                                                                                                
    
    作为依赖被安装:
      docker-ce-cli.x86_64 1:20.10.10-3.el7            docker-ce-rootless-extras.x86_64 0:20.10.10-3.el7            docker-scan-plugin.x86_64 0:0.9.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                
    
    作为依赖被升级:
      containerd.io.x86_64 0:1.4.11-3.1.el7                                                                                                                            
    
    完毕!
    [root@jumpserver ~]# 

    7.启动并加入开机启动

    $ sudo systemctl start docker
    $ sudo systemctl enable docker
    [root@jumpserver ~]# systemctl start docker
    [root@jumpserver ~]# systemctl enable docker
    [root@jumpserver ~]# service docker status
    Redirecting to /bin/systemctl status docker.service
    ● docker.service - Docker Application Container Engine
       Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
       Active: active (running) since 日 2021-10-31 16:14:25 CST; 58s ago
         Docs: https://docs.docker.com
     Main PID: 36821 (dockerd)
       CGroup: /system.slice/docker.service
               ├─36821 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
               ├─36936 /usr/bin/docker-proxy -proto tcp -host-ip 127.0.0.1 -host-port 5000 -container-ip 172.17.0.2 -container-port 5000
               ├─36948 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 2222 -container-ip 172.17.0.2 -container-port 2222
               ├─36953 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 2222 -container-ip 172.17.0.2 -container-port 2222
               └─36967 /usr/bin/docker-proxy -proto tcp -host-ip 127.0.0.1 -host-port 8081 -container-ip 172.17.0.3 -container-port 8080
    
    10月 31 16:14:24 jumpserver dockerd[36821]: time="2021-10-31T16:14:24.031172853+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[{uni...dule=grpc
    10月 31 16:14:24 jumpserver dockerd[36821]: time="2021-10-31T16:14:24.031181898+08:00" level=info msg="ClientConn switching balancer to "pick_first"...dule=grpc
    10月 31 16:14:24 jumpserver dockerd[36821]: time="2021-10-31T16:14:24.040976909+08:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
    10月 31 16:14:24 jumpserver dockerd[36821]: time="2021-10-31T16:14:24.192379618+08:00" level=info msg="Loading containers: start."
    10月 31 16:14:24 jumpserver dockerd[36821]: time="2021-10-31T16:14:24.338495836+08:00" level=info msg="Default bridge (docker0) is assigned with an IP... address"
    10月 31 16:14:24 jumpserver dockerd[36821]: time="2021-10-31T16:14:24.977777910+08:00" level=info msg="Loading containers: done."
    10月 31 16:14:25 jumpserver dockerd[36821]: time="2021-10-31T16:14:25.029481200+08:00" level=info msg="Docker daemon" commit=e2f740d graphdriver(s)=ov...=20.10.10
    10月 31 16:14:25 jumpserver dockerd[36821]: time="2021-10-31T16:14:25.029570736+08:00" level=info msg="Daemon has completed initialization"
    10月 31 16:14:25 jumpserver systemd[1]: Started Docker Application Container Engine.
    10月 31 16:14:25 jumpserver dockerd[36821]: time="2021-10-31T16:14:25.091101549+08:00" level=info msg="API listen on /var/run/docker.sock"
    Hint: Some lines were ellipsized, use -l to show in full.
    [root@jumpserver ~]# docker version
    Client: Docker Engine - Community
     Version:           20.10.10
     API version:       1.41
     Go version:        go1.16.9
     Git commit:        b485636
     Built:             Mon Oct 25 07:44:50 2021
     OS/Arch:           linux/amd64
     Context:           default
     Experimental:      true
    
    Server: Docker Engine - Community
     Engine:
      Version:          20.10.10
      API version:      1.41 (minimum version 1.12)
      Go version:       go1.16.9
      Git commit:       e2f740d
      Built:            Mon Oct 25 07:43:13 2021
      OS/Arch:          linux/amd64
      Experimental:     false
     containerd:
      Version:          1.4.11
      GitCommit:        5b46e404f6b9f661a205e28d59c982d3634148f8
     runc:
      Version:          1.0.2
      GitCommit:        v1.0.2-0-g52b36a2
     docker-init:
      Version:          0.19.0
      GitCommit:        de40ad0
    [root@jumpserver ~]# 
    始终相信美好的事情即将发生
  • 相关阅读:
    New version of VS2005 extensions for SharePoint 3.0
    QuickPart : 用户控件包装器 for SharePoint Server 2007
    随想
    发布 SharePoint Server 2007 Starter Page
    如何在SharePoint Server中整合其他应用系统?
    Office SharePoint Server 2007 中文180天评估版到货!
    RMS 1.0 SP2
    SharePoint Server 2007 Web内容管理中的几个关键概念
    如何为已存在的SharePoint站点启用SSL
    Some update information about Office 2007
  • 原文地址:https://www.cnblogs.com/subsea/p/15489614.html
Copyright © 2011-2022 走看看