• Docker镜像的获取和推送


      查找镜像

      查找镜像的方法有主要有两种,一种是在Docker Hub官方网站查找,网址为https://hub.docker.com/

      另一种方法是在命令行界面中通过docker serach <image>来查找相关的镜像。

      docker search命令说明:

    docker search [options] TERM
        --authomated=false    Only show automated builds
        --no-trunc=false    Don't truncate output
        -s,--stars=0    Only displays with at least x stars
        最多返回25个结果
    View Code

      docker search ubuntu结果:

    [root@docker ~]# docker search ubuntu
    NAME                       DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
    ubuntu                     Ubuntu is a Debian-based Linux operating s...   6281      [OK]       
    rastasheep/ubuntu-sshd     Dockerized SSH service, built on top of of...   91                   [OK]
    ubuntu-upstart             Upstart is an event-based replacement for ...   74        [OK]       
    neurodebian                NeuroDebian provides neuroscience research...   37        [OK]       
    ubuntu-debootstrap         debootstrap --variant=minbase --components...   30        [OK]       
    32bit/ubuntu               Ubuntu for i386 (32bit)                         30                   
    armhf/ubuntu               Ubuntu is a Debian-based Linux operating s...   27                   
    nuagebec/ubuntu            Simple always updated Ubuntu docker images...   22                   [OK]
    tutum/ubuntu               Simple Ubuntu docker images with SSH access     18                   
    ppc64le/ubuntu             Ubuntu is a Debian-based Linux operating s...   10                   
    aarch64/ubuntu             Ubuntu is a Debian-based Linux operating s...   9                    
    sameersbn/ubuntu                                                           9                    [OK]
    i386/ubuntu                Ubuntu is a Debian-based Linux operating s...   7                    
    nimmis/ubuntu              This is a docker images different LTS vers...   7                    [OK]
    darksheer/ubuntu           Base Ubuntu Image -- Updated hourly             3                    [OK]
    libmesos/ubuntu                                                            3                    
    scaleway/ubuntu            Ubuntu image on Scaleway                        2                    
    webhippie/ubuntu           Docker images for ubuntu                        1                    [OK]
    vcatechnology/ubuntu       A Ubuntu image that is updated daily            1                    [OK]
    s390x/ubuntu               Ubuntu is a Debian-based Linux operating s...   1                    
    konstruktoid/ubuntu        Ubuntu base image                               0                    [OK]
    smartentry/ubuntu          ubuntu with smartentry                          0                    [OK]
    ossobv/ubuntu              Custom ubuntu image from scratch (based on...   0                    
    defensative/socat-ubuntu                                                   0                    [OK]
    pivotaldata/ubuntu         A quick freshening-up of the base Ubuntu d...   0                    
    [root@docker ~]# 
    View Code

      查找3星以上的ubuntu镜像:

    [root@docker ~]# docker search -s 3 ubuntu
    Flag --stars has been deprecated, use --filter=stars=3 instead
    NAME                     DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
    ubuntu                   Ubuntu is a Debian-based Linux operating s...   6281      [OK]       
    rastasheep/ubuntu-sshd   Dockerized SSH service, built on top of of...   91                   [OK]
    ubuntu-upstart           Upstart is an event-based replacement for ...   74        [OK]       
    neurodebian              NeuroDebian provides neuroscience research...   37        [OK]       
    ubuntu-debootstrap       debootstrap --variant=minbase --components...   30        [OK]       
    32bit/ubuntu             Ubuntu for i386 (32bit)                         30                   
    armhf/ubuntu             Ubuntu is a Debian-based Linux operating s...   27                   
    nuagebec/ubuntu          Simple always updated Ubuntu docker images...   22                   [OK]
    tutum/ubuntu             Simple Ubuntu docker images with SSH access     18                   
    ppc64le/ubuntu           Ubuntu is a Debian-based Linux operating s...   10                   
    aarch64/ubuntu           Ubuntu is a Debian-based Linux operating s...   9                    
    sameersbn/ubuntu                                                         9                    [OK]
    i386/ubuntu              Ubuntu is a Debian-based Linux operating s...   7                    
    nimmis/ubuntu            This is a docker images different LTS vers...   7                    [OK]
    darksheer/ubuntu         Base Ubuntu Image -- Updated hourly             3                    [OK]
    libmesos/ubuntu                                                          3                    
    [root@docker ~]# 
    View Code

      拉取镜像

      镜像通过"docker pull <image>"拉取。

      docker pull命令简单说明:

    docker pull [options] NAME[:TAG]
        -a,--all-tags=false    Download all tagged images in the repository
    View Code

      拉取ubuntu:14.04镜像:

    [root@CentOS7 ~]# docker pull ubuntu:14.04
    14.04: Pulling from library/ubuntu
    cb56c90f0b30: Pull complete 
    0acc551e5716: Pull complete 
    8956dcd35143: Pull complete 
    908242721214: Pull complete 
    b44ff14dd3bb: Pull complete 
    Digest: sha256:5faf6cb681da2be979a177b60d8c18497f962e3d82268c49db6c74008d0c294d
    Status: Downloaded newer image for ubuntu:14.04
    [root@CentOS7 ~]#
    View Code

      拉取成功后可以通过docker images查看本地镜像:

    [root@CentOS7 ~]# docker images
    REPOSITORY                              TAG                 IMAGE ID            CREATED             SIZE
    jie/df_test1                            latest              cd7c340503bc        3 hours ago         214MB
    centos/nginx                            latest              e5faa74eeb5d        5 hours ago         401MB
    php                                     latest              2dbd5ab1d9f5        4 days ago          370MB
    nginx                                   latest              e4e6d42c70b3        5 days ago          107MB
    centos                                  latest              36540f359ca3        11 days ago         193MB
    registry                                latest              c2a449c9f834        2 weeks ago         33.2MB
    mysql                                   latest              44a8e1a5c0b2        3 weeks ago         407MB
    ubuntu                                  latest              d355ed3537e9        3 weeks ago         119MB
    ubuntu                                  14.04               4a2820e686c4        3 weeks ago         188MB
    daocloud.io/daocloud/daocloud-toolset   latest              bbdc71e950ea        4 months ago        147MB
    [root@CentOS7 ~]#
    View Code

      由于国内的特殊原因,镜像拉取特别慢,很容易下载失败。所以我们可以使用加速器来加速下载,提高下载成功率,现有的比如网易蜂巢加速器、阿里云加速器和daocloud加速器等。可以根据自己喜好选用。

      推送镜像(需要拥有Docker Hub的账号)

      我们自己构建镜像之后可以通过docker push <image>将自己的镜像推送至Docker Hub仓库中,前提是需要有自己的Docker Hub账号。免费的账号只能有一个存储空间,当然Docker Hub支持付费服务,增加可用空间。

    [root@docker ~]# docker push jie/df_test1
    The push refers to a repository [docker.io/jie/df_test1]
    sending image list
    
    please login prior to push:
    Username:staryjie
    Password:
    Email:fngje0128@163.com
    Login Successed
    The push refers to a repository [docker.io/jie/df_test1]
    f5456bfd299d: Pushing 
    8f2ab3b3ad55: Waiting 
    0566c118947e: Preparing 
    6f9cf951edf5: Waiting 
    182d2a55830d: Preparing 
    5a4c2c9a24fc: Preparing 
    cb11ba605400: Waiting
    View Code

      等待push完成,上传完成之后即可在Docker Hub中自己的仓库中看到,也可以通过网页搜索查看,如果不想公开,也可以设置镜像为个人,这样别人就无法查看到你的镜像了。

  • 相关阅读:
    杭州办理招行香港一卡通(两地一卡通)攻略
    Android高手进阶教程(二十)之Android与JavaScript方法相互调用!
    Android应用的自动升级、更新模块的实现
    18个最好的jQuery表格插件
    系统的本地策略不允许你采用交互式登录
    android中判断横屏或者竖屏并改变背景
    记录几个东东
    jsAnim学习
    win7下安装oracle10g出现未知错误,程序异常终止
    oracle创建用户并授权
  • 原文地址:https://www.cnblogs.com/jie-fang/p/7207549.html
Copyright © 2020-2023  润新知