zoukankan      html  css  js  c++  java
  • linux安装docker

      我们在普通用户下执行docker安装操作,所以需要加上sudo来暂时获取root权限。

      安装相关软件:

    [mall@VM_0_7_centos ~]$ sudo yum -y install yum-utils device-mapper-persistent-data 1vm2

      配置仓库:

    [mall@VM_0_7_centos ~]$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    [sudo] password for mall: 
    Loaded plugins: fastestmirror, langpacks
    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

      安装:

    [mall@VM_0_7_centos ~]$ sudo yum install docker-ce
    Loaded plugins: fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
    docker-ce-stable                                                                                                                                | 3.5 kB  00:00:00     
    (1/2): docker-ce-stable/x86_64/updateinfo                                                                                                       |   55 B  00:00:00     
    (2/2): docker-ce-stable/x86_64/primary_db                                                                                                       |  37 kB  00:00:00     
    Resolving Dependencies
    --> Running transaction check
    ---> Package docker-ce.x86_64 3:19.03.4-3.el7 will be installed
    --> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-19.03.4-3.el7.x86_64
    --> Processing Dependency: containerd.io >= 1.2.2-3 for package: 3:docker-ce-19.03.4-3.el7.x86_64
    --> Processing Dependency: docker-ce-cli for package: 3:docker-ce-19.03.4-3.el7.x86_64
    --> Processing Dependency: libcgroup for package: 3:docker-ce-19.03.4-3.el7.x86_64
    --> Running transaction check
    ---> Package container-selinux.noarch 2:2.107-3.el7 will be installed
    --> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.107-3.el7.noarch
    ---> Package containerd.io.x86_64 0:1.2.10-3.2.el7 will be installed
    ---> Package docker-ce-cli.x86_64 1:19.03.4-3.el7 will be installed
    ---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
    --> Running transaction check
    ---> Package policycoreutils-python.x86_64 0:2.5-33.el7 will be installed
    --> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-33.el7.x86_64
    --> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-33.el7.x86_64
    --> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-33.el7.x86_64
    --> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-33.el7.x86_64
    --> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
    --> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
    --> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
    --> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-33.el7.x86_64
    --> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
    --> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
    --> Running transaction check
    ---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
    ---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
    ---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
    ---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
    ---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =======================================================================================================================================================================
     Package                                        Arch                           Version                                  Repository                                Size
    =======================================================================================================================================================================
    Installing:
     docker-ce                                      x86_64                         3:19.03.4-3.el7                          docker-ce-stable                          24 M
    Installing for dependencies:
     audit-libs-python                              x86_64                         2.8.5-4.el7                              os                                        76 k
     checkpolicy                                    x86_64                         2.5-8.el7                                os                                       295 k
     container-selinux                              noarch                         2:2.107-3.el7                            extras                                    39 k
     containerd.io                                  x86_64                         1.2.10-3.2.el7                           docker-ce-stable                          23 M
     docker-ce-cli                                  x86_64                         1:19.03.4-3.el7                          docker-ce-stable                          39 M
     libcgroup                                      x86_64                         0.41-21.el7                              os                                        66 k
     libsemanage-python                             x86_64                         2.5-14.el7                               os                                       113 k
     policycoreutils-python                         x86_64                         2.5-33.el7                               os                                       457 k
     python-IPy                                     noarch                         0.75-6.el7                               os                                        32 k
     setools-libs                                   x86_64                         3.3.8-4.el7                              os                                       620 k
    
    Transaction Summary
    =======================================================================================================================================================================
    Install  1 Package (+10 Dependent packages)
    
    Total download size: 89 M
    Installed size: 368 M
    Is this ok [y/d/N]: y
    Downloading packages:
    (1/11): container-selinux-2.107-3.el7.noarch.rpm                                                                                                |  39 kB  00:00:00     
    (2/11): audit-libs-python-2.8.5-4.el7.x86_64.rpm                                                                                                |  76 kB  00:00:00     
    (3/11): checkpolicy-2.5-8.el7.x86_64.rpm                                                                                                        | 295 kB  00:00:00     
    warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-19.03.4-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY MB  00:00:04 ETA 
    Public key for docker-ce-19.03.4-3.el7.x86_64.rpm is not installed
    (4/11): docker-ce-19.03.4-3.el7.x86_64.rpm                                                                                                      |  24 MB  00:00:02     
    (5/11): containerd.io-1.2.10-3.2.el7.x86_64.rpm                                                                                                 |  23 MB  00:00:02     
    (6/11): libcgroup-0.41-21.el7.x86_64.rpm                                                                                                        |  66 kB  00:00:00     
    (7/11): libsemanage-python-2.5-14.el7.x86_64.rpm                                                                                                | 113 kB  00:00:00     
    (8/11): python-IPy-0.75-6.el7.noarch.rpm                                                                                                        |  32 kB  00:00:00     
    (9/11): policycoreutils-python-2.5-33.el7.x86_64.rpm                                                                                            | 457 kB  00:00:00     
    (10/11): setools-libs-3.3.8-4.el7.x86_64.rpm                                                                                                    | 620 kB  00:00:00     
    (11/11): docker-ce-cli-19.03.4-3.el7.x86_64.rpm                                                                                                 |  39 MB  00:00:04     
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Total                                                                                                                                   14 MB/s |  89 MB  00:00:06     
    Retrieving key from https://download.docker.com/linux/centos/gpg
    Importing GPG key 0x621E9F35:
     Userid     : "Docker Release (CE rpm) <docker@docker.com>"
     Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
     From       : https://download.docker.com/linux/centos/gpg
    Is this ok [y/N]: y
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : libcgroup-0.41-21.el7.x86_64                                                                                                                       1/11 
      Installing : setools-libs-3.3.8-4.el7.x86_64                                                                                                                    2/11 
      Installing : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                               3/11 
      Installing : python-IPy-0.75-6.el7.noarch                                                                                                                       4/11 
      Installing : libsemanage-python-2.5-14.el7.x86_64                                                                                                               5/11 
      Installing : 1:docker-ce-cli-19.03.4-3.el7.x86_64                                                                                                               6/11 
      Installing : checkpolicy-2.5-8.el7.x86_64                                                                                                                       7/11 
      Installing : policycoreutils-python-2.5-33.el7.x86_64                                                                                                           8/11 
      Installing : 2:container-selinux-2.107-3.el7.noarch                                                                                                             9/11 
    setsebool:  SELinux is disabled.
      Installing : containerd.io-1.2.10-3.2.el7.x86_64                                                                                                               10/11 
      Installing : 3:docker-ce-19.03.4-3.el7.x86_64                                                                                                                  11/11 
      Verifying  : checkpolicy-2.5-8.el7.x86_64                                                                                                                       1/11 
      Verifying  : policycoreutils-python-2.5-33.el7.x86_64                                                                                                           2/11 
      Verifying  : 1:docker-ce-cli-19.03.4-3.el7.x86_64                                                                                                               3/11 
      Verifying  : 3:docker-ce-19.03.4-3.el7.x86_64                                                                                                                   4/11 
      Verifying  : libsemanage-python-2.5-14.el7.x86_64                                                                                                               5/11 
      Verifying  : 2:container-selinux-2.107-3.el7.noarch                                                                                                             6/11 
      Verifying  : python-IPy-0.75-6.el7.noarch                                                                                                                       7/11 
      Verifying  : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                               8/11 
      Verifying  : containerd.io-1.2.10-3.2.el7.x86_64                                                                                                                9/11 
      Verifying  : setools-libs-3.3.8-4.el7.x86_64                                                                                                                   10/11 
      Verifying  : libcgroup-0.41-21.el7.x86_64                                                                                                                      11/11 
    
    Installed:
      docker-ce.x86_64 3:19.03.4-3.el7                                                                                                                                     
    
    Dependency Installed:
      audit-libs-python.x86_64 0:2.8.5-4.el7   checkpolicy.x86_64 0:2.5-8.el7      container-selinux.noarch 2:2.107-3.el7   containerd.io.x86_64 0:1.2.10-3.2.el7       
      docker-ce-cli.x86_64 1:19.03.4-3.el7     libcgroup.x86_64 0:0.41-21.el7      libsemanage-python.x86_64 0:2.5-14.el7   policycoreutils-python.x86_64 0:2.5-33.el7  
      python-IPy.noarch 0:0.75-6.el7           setools-libs.x86_64 0:3.3.8-4.el7  
    
    Complete!

      启动并验证:

    [mall@VM_0_7_centos ~]$ sudo systemctl start docker
    [sudo] password for mall: 
    [mall@VM_0_7_centos ~]$ sudo docker run hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    1b930d010525: Pull complete 
    Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
    Status: Downloaded newer image for hello-world:latest
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    
    To generate this message, Docker took the following steps:
     1. The Docker client contacted the Docker daemon.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (amd64)
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
    
    To try something more ambitious, you can run an Ubuntu container with:
     $ docker run -it ubuntu bash
    
    Share images, automate workflows, and more with a free Docker ID:
     https://hub.docker.com/
    
    For more examples and ideas, visit:
     https://docs.docker.com/get-started/

      起来后我们试试拉取一个mysql镜像:

    [mall@VM_0_7_centos ~]$ sudo docker pull mysql:5.7
    5.7: Pulling from library/mysql
    80369df48736: Pull complete 
    e8f52315cb10: Pull complete 
    cf2189b391fc: Pull complete 
    cc98f645c682: Pull complete 
    27a27ac83f74: Pull complete 
    fa1f04453414: Pull complete 
    d45bf7d22d33: Pull complete 
    c7d49ffebc56: Pull complete 
    511a8052b204: Pull complete 
    5d5df4c12444: Pull complete 
    d482603a2922: Pull complete 
    Digest: sha256:44b33224e3c406bf50b5a2ee4286ed0d7f2c5aec1f7fdb70291f7f7c570284dd
    Status: Downloaded newer image for mysql:5.7
    docker.io/library/mysql:5.7

      

  • 相关阅读:
    面向对象介绍
    常用模块2
    常用模块1
    常用模块3
    模块导入以及常用模块
    模块介绍
    Astra: Apache Cassandra的未来是云原生
    麦格理银行借助DataStax Enterprise (DSE) 驱动数字化转型
    Apache Cassandra使用报告2020
    比较Apache Cassandra的压力测试工具
  • 原文地址:https://www.cnblogs.com/wuxun1997/p/11766254.html
Copyright © 2011-2022 走看看