IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Docker 镜像管理

    村里来的扫地僧发表于 2016-03-17 09:23:11
    love 0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    
    查看镜像:
    [root@localhost ~]# docker images
     
    搜索镜像:
    [root@localhost ~]# docker search centos
    NAME                            DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
    centos                          The official build of CentOS.                   2028      [OK]       
    jdeathe/centos-ssh              CentOS-6 6.7 x86_64 / CentOS-7 7.2.1511 x8...   17                   [OK]
    jdeathe/centos-ssh-apache-php   CentOS-6 6.7 x86_64 / Apache / PHP / PHP M...   14                   [OK]
    million12/centos-supervisor     Base CentOS-7 with supervisord launcher, h...   9                    [OK]
    blalor/centos                   Bare-bones base CentOS 6.5 image                8                    [OK]
    nimmis/java-centos              This is docker images of CentOS 7 with dif...   7                    [OK]
    torusware/speedus-centos        Always updated official CentOS docker imag...   7                    [OK]
    nickistre/centos-lamp           LAMP on centos setup                            3                    [OK]
    nathonfowlie/centos-jre         Latest CentOS image with the JRE pre-insta...   3                    [OK]
    centos/mariadb55-centos7                                                        3                    [OK]
    consol/sakuli-centos-xfce       Sakuli end-2-end testing and monitoring co...   2                    [OK]
    timhughes/centos                Centos with systemd installed and running       1                    [OK]
    lighthopper/orientdb-centos     A Dockerfile for creating an OrientDB imag...   1                    [OK]
    layerworx/centos                CentOS container with etcd, etcdctl, confd...   1                    [OK]
    yajo/centos-epel                CentOS with EPEL and fully updated              1                    [OK]
    pacur/centos-7                  Pacur CentOS 7                                  1                    [OK]
    softvisio/centos                Centos                                          1                    [OK]
    darksheer/centos                Base Centos Image -- Updated hourly             1                    [OK]
    pacur/centos-6                  Pacur CentOS 6                                  1                    [OK]
    ustclug/centos                   USTC centos                                    0                    [OK]
    blacklabelops/centos            CentOS Base Image! Built and Updates Daily!     0                    [OK]
    jsmigel/centos-epel             Docker base image of CentOS w/ EPEL installed   0                    [OK]
    lighthopper/openjdk-centos      A Dockerfile for creating an OpenJDK image...   0                    [OK]
    grayzone/centos                 auto build for centos.                          0                    [OK]
    januswel/centos                 yum update-ed CentOS image                      0                    [OK]
     
    获取镜像:
    [root@localhost ~]# docker pull centos
    latest: Pulling from centos
    47d44cb6f252: Pull complete 
    6fdebd7b0eb5: Pull complete 
    a63aae4d216f: Pull complete 
    bb3d629a7cbc: Pull complete 
    Digest: sha256:381f21e4c7b3724c6f420b2bcfa6e13e47ed155192869a2a04fa10f944c78476
    Status: Downloaded newer image for centos:latest
    [root@localhost ~]# 
     
    为镜像设置标签:
    [root@localhost ~]# docker tag centos centos123
    [root@localhost ~]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    centos              latest              bb3d629a7cbc        9 days ago          196.6 MB
    centos123           latest              bb3d629a7cbc        9 days ago          196.6 MB
     
    查看运行的镜像:
    [root@localhost ~]# docker ps
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    807db1718ddd        centos              "/bin/bash"         2 minutes ago       Up 2 minutes                            high_kirch          
    [root@localhost ~]# 
     
    启动Docker的容器:
    [root@localhost ~]# docker run -t -i centos /bin/bash 
     
    进入一个容器:
    [root@localhost ~]# docker exec -it ccd92ca4baae /bin/bash 
     
    安装net-tools:
    [root@ccd92ca4baae /]# yum install -y net-tools wget
    Loaded plugins: fastestmirror, ovl
    base                                                                                              | 3.6 kB  00:00:00     
    extras                                                                                            | 3.4 kB  00:00:00     
    updates                                                                                           | 3.4 kB  00:00:00     
    (1/4): extras/7/x86_64/primary_db                                                                 | 101 kB  00:00:00     
    (2/4): updates/7/x86_64/primary_db                                                                | 3.2 MB  00:00:01     
    (3/4): base/7/x86_64/group_gz                                                                     | 155 kB  00:00:02     
    (4/4): base/7/x86_64/primary_db                                                                   | 5.3 MB  00:00:05     
    Determining fastest mirrors
     * base: mirrors.skyshe.cn
     * extras: mirrors.aliyun.com
     * updates: mirrors.yun-idc.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package net-tools.x86_64 0:2.0-0.17.20131004git.el7 will be installed
    ---> Package wget.x86_64 0:1.14-10.el7_0.1 will be installed
    --> Finished Dependency Resolution
     
    Dependencies Resolved
     
    =========================================================================================================================
     Package                   Arch                   Version                                     Repository            Size
    =========================================================================================================================
    Installing:
     net-tools                 x86_64                 2.0-0.17.20131004git.el7                    base                 304 k
     wget                      x86_64                 1.14-10.el7_0.1                             base                 545 k
     
    Transaction Summary
    =========================================================================================================================
    Install  2 Packages
     
    Total download size: 849 k
    Installed size: 2.9 M
    Downloading packages:
    warning: /var/cache/yum/x86_64/7/base/packages/wget-1.14-10.el7_0.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    Public key for wget-1.14-10.el7_0.1.x86_64.rpm is not installed
    (1/2): wget-1.14-10.el7_0.1.x86_64.rpm                                                            | 545 kB  00:00:00     
    (2/2): net-tools-2.0-0.17.20131004git.el7.x86_64.rpm                                              | 304 kB  00:00:00     
    -------------------------------------------------------------------------------------------------------------------------
    Total                                                                                    891 kB/s | 849 kB  00:00:00     
    Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    Importing GPG key 0xF4A80EB5:
     Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
     Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
     Package    : centos-release-7-2.1511.el7.centos.2.10.x86_64 (@CentOS)
     From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : net-tools-2.0-0.17.20131004git.el7.x86_64                                                             1/2 
      Installing : wget-1.14-10.el7_0.1.x86_64                                                                           2/2 
    install-info: No such file or directory for /usr/share/info/wget.info.gz
      Verifying  : wget-1.14-10.el7_0.1.x86_64                                                                           1/2 
      Verifying  : net-tools-2.0-0.17.20131004git.el7.x86_64                                                             2/2 
     
    Installed:
      net-tools.x86_64 0:2.0-0.17.20131004git.el7                        wget.x86_64 0:1.14-10.el7_0.1                       
     
    Complete!


沪ICP备19023445号-2号
友情链接