将Docker映像推送到注册表

技术提示#57说明了如何创建自己的Docker映像。 那个特定的博客专门展示了如何在CentOS和Ubuntu上构建自己的WildFly Docker映像。 现在,您可以与世界其他地方分享您的图像了。 这就是Docker Hub派上用场的地方。

Docker Hub是Docker的“分发组件”,或者是存储和搜索映像的地方。 从《 Docker Hub入门》文档中……

Docker Hub是用于处理Docker及其组件的集中资源。 Docker Hub可帮助您与同事协作并充分利用Docker。

使用Docker Hub启动和推送映像非常简单。

  • 将映像推送到Docker Hub需要一个帐户。 可以按照此处的说明进行创建。 或者使用docker login命令轻松实现。
    wildfly-centos> docker login
    Username: arungupta
    Password: 
    Email: [email protected]
    Login Succeeded

    在WildFly上搜索显示有72张图像:

    wildfly-centos> docker search wildfly
    NAME                                     DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
    jboss/wildfly                            WildFly application server image                42                   [OK]
    sewatech/wildfly                         Debian + WildFly 8.1.0.Final with OpenJDK ...   1                    [OK]
    kamcord/wildfly                                                                          1                    
    openshift/wildfly-8-centos                                                               1                    [OK]
    abstractj/wildfly                        AeroGear Wildfly Docker image                   1                    
    jsightler/wildfly_nightly                Nightly build from wildfly's github master...   1                    
    centos/wildfly                           CentOS based WildFly Docker image               1                    
    aerogear/unifiedpush-wildfly                                                             1                    [OK]
    t0nyhays/wildfly                                                                         1                    [OK]
    tsuckow/wildfly-propeller                Dockerization of my application *Propeller...   0                    [OK]
    n3ziniuka5/wildfly                                                                       0                    [OK]
    snasello/wildfly                                                                         0                    [OK]
    jboss/keycloak-adapter-wildfly                                                           0                    [OK]
    emsouza/wildfly                                                                          0                    [OK]
    sillenttroll/wildfly-java-8              WildFly container with java 8                   0                    [OK]
    jboss/switchyard-wildfly                                                                 0                    [OK]
    n3ziniuka5/wildfly-jrebel                                                                0                    [OK]
    dfranssen/docker-wildfly                                                                 0                    [OK]
    wildflyext/wildfly-camel                 WildFly with Camel Subsystem                    0                    
    ianblenke/wildfly                                                                        0                    [OK]
    arcamael/docker-wildfly                                                                  0                    [OK]
    dmartin/wildfly                                                                          0                    [OK]
    pires/wildfly-cluster-backend                                                            0                    [OK]
    aerogear/push-quickstarts-wildfly-dev                                                    0                    [OK]
    faga/wildfly                             Wildfly application server with ubuntu.         0                    
    abstractj/unifiedpush-wildfly            AeroGear Wildfly Docker image                   0                    
    murad/wildfly                            - oficial centos image - java JDK "1.8.0_0...   0                    
    aerogear/unifiedpush-wildfly-dev                                                         0                    [OK]
    ianblenke/wildfly-cluster                                                                0                    [OK]
    blackhm/wildfly                                                                          0                    
    khipu/wildfly8                                                                           0                    [OK]
    rowanto/docker-wheezy-wildfly-java8                                                      0                    [OK]
    ordercloud/wildfly                                                                       0                    
    lavaliere/je-wildfly                     A Jenkins Enterprise demo master with a Wi...   0                    
    adorsys/wildfly                          Ubuntu - Wildfly - Base Image                   0                    
    akalliya/wildfly                                                                         0                    
    lavaliere/joc-wildfly                    Jenkins Operations Center master with an a...   0                    
    tdiesler/wildfly                                                                         0                    
    apiman/on-wildfly8                                                                       0                    [OK]
    rowanto/docker-wheezy-wildfly-java8-ex                                                   0                    [OK]
    arcamael/blog-wildfly                                                                    0                    
    lavaliere/wildfly                                                                        0                    
    jfaerman/wildfly                                                                         0                    
    yntelectual/wildfly                                                                      0                    
    svenvintges/wildfly                                                                      0                    
    dbrotsky/wildfly                                                                         0                    
    luksa/wildfly                                                                            0                    
    tdiesler/wildfly-camel                                                                   0                    
    blackhm/wildfly-junixsocket                                                              0                    
    abstractj/unifiedpush-wildfly-dev        AeroGear UnifiedPush server developer envi...   0                    
    abstractj/push-quickstarts-wildfly-dev   AeroGear UnifiedPush Quickstarts developer...   0                    
    bn3t/wildfly-wicket-examples             An image to run the wicket-examples on wil...   0                    
    lavaliere/wildfly-1                                                                      0                    
    munchee13/wildfly-node                                                                   0                    
    munchee13/wildfly-manager                                                                0                    
    munchee13/wildfly-dandd                                                                  0                    
    munchee13/wildfly-admin                                                                  0                    
    bparees/wildfly-8-centos                                                                 0                    
    lecoz/wildflysiolapie                    fedora latest, jdk1.8.0_25, wildfly-8.1.0....   0                    
    lecoz/wildflysshsiolapie                 wildfly 8.1.0.Final, jdk1.8.0_25, sshd, fe...   0                    
    wildflyext/example-camel-rest                                                            0                    
    pepedigital/wildfly                                                                      0                    [OK]
    tsuckow/wildfly                          JBoss Wildfly 8.1.0.Final standalone mode ...   0                    [OK]
    mihahribar/wildfly                       Dockerfile for Wildfly running on Ubuntu 1...   0                    [OK]
    hpehl/wildfly-domain                     Dockerfiles based on "jboss/wildfly" to se...   0                    [OK]
    raynera/wildfly                                                                          0                    [OK]
    hpehl/wildfly-standalone                 Dockerfile based on jboss/wildfly to setup...   0                    [OK]
    aerogear/wildfly                                                                         0                    [OK]
    piegsaj/wildfly                                                                          0                    [OK]
    wildflyext/wildfly                       Tagged versions JBoss WildFly                   0

    官方图片被标记为jboss/wildfly

  • 为了推送您自己的图像,需要将其构建为命名图像,否则将显示如下错误:
    2014/11/26 09:59:37 You cannot push a "root" repository. Please rename your repository in / (ex: arungupta/wildfly-centos)

    可以很容易地完成,如下所示:

    wildfly-centos> docker build -t="arungupta/wildfly-centos" .
    Sending build context to Docker daemon 4.096 kB
    Sending build context to Docker daemon 
    Step 0 : FROM centos
     ---> ae0c2d0bdc10
    Step 1 : MAINTAINER Arun Gupta 
          
           
     ---> Using cache
     ---> e490dfcb3685
    Step 2 : RUN yum -y update && yum clean all
     ---> Using cache
     ---> f212cb9dbcf5
    Step 3 : RUN yum -y install xmlstarlet saxon augeas bsdtar unzip && yum clean all
     ---> Using cache
     ---> 28b11e6151f0
    Step 4 : RUN groupadd -r jboss -g 1000 && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss
     ---> Using cache
     ---> 73603eab89b7
    Step 5 : WORKDIR /opt/jboss
     ---> Using cache
     ---> 9a661ae4341b
    Step 6 : USER jboss
     ---> Using cache
     ---> 6265153611c7
    Step 7 : USER root
     ---> Using cache
     ---> 12ed28a7acb7
    Step 8 : RUN yum -y install java-1.7.0-openjdk-devel && yum clean all
     ---> Using cache
     ---> 44c4bb92fa11
    Step 9 : USER jboss
     ---> Using cache
     ---> 930cb2a860f7
    Step 10 : ENV JAVA_HOME /usr/lib/jvm/java
     ---> Using cache
     ---> fff2c21b0a71
    Step 11 : ENV WILDFLY_VERSION 8.2.0.Final
     ---> Using cache
     ---> b7b7ca7a9172
    Step 12 : RUN cd $HOME && curl -O http://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.zip && unzip wildfly-$WILDFLY_VERSION.zip && mv $HOME/wildfly-$WILDFLY_VERSION $HOME/wildfly && rm wildfly-$WILDFLY_VERSION.zip
     ---> Using cache
     ---> a1bc79a43c77
    Step 13 : ENV JBOSS_HOME /opt/jboss/wildfly
     ---> Using cache
     ---> d46fdd618d55
    Step 14 : EXPOSE 8080 9990
     ---> Running in 9c2c2a5ef41c
     ---> 8988c8cbc051
    Removing intermediate container 9c2c2a5ef41c
    Step 15 : CMD /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0
     ---> Running in 9e28c3449ec1
     ---> d989008d1f84
    Removing intermediate container 9e28c3449ec1
    Successfully built d989008d1f84
    
          

    docker build命令生成映像, -t指定要应用于结果映像的存储库名称。

  • 构建映像后,可以将其验证为:
    wildfly-centos> docker images
    REPOSITORY                 TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    arungupta/wildfly-centos   latest              d989008d1f84        14 hours ago        619.6 MB
    wildfly-ubuntu             latest              a2e96e76eb10        43 hours ago        749.5 MB
    
                               
           
                          0281986b0ed8        44 hours ago        749.5 MB
    
                                 
             
                            1a5e1aeadc85        44 hours ago        607.7 MB
    wildfly-centos             latest              97c8780a7d6a        45 hours ago        619.6 MB
    registry                   latest              7e2db37c6564        13 days ago         411.6 MB
    centos                     latest              ae0c2d0bdc10        3 weeks ago         224 MB
    jboss/wildfly              latest              365390553f92        4 weeks ago         948.7 MB
    ubuntu                     latest              5506de2b643b        4 weeks ago         199.3 MB
    
             
            
           
          

    注意第一行显示了命名图像arungupta/wildfly-centos

  • 然后可以将该映像按以下方式推送到Docker Hub:
    wildfly-centos> docker push arungupta/wildfly-centos
    The push refers to a repository [arungupta/wildfly-centos] (len: 1)
    Sending image list
    Pushing repository arungupta/wildfly-centos (1 tags)
    511136ea3c5a: Image already pushed, skipping 
    5b12ef8fd570: Image already pushed, skipping 
    ae0c2d0bdc10: Image already pushed, skipping 
    e490dfcb3685: Image successfully pushed 
    f212cb9dbcf5: Image successfully pushed 
    28b11e6151f0: Image successfully pushed 
    73603eab89b7: Image successfully pushed 
    9a661ae4341b: Image successfully pushed 
    6265153611c7: Image successfully pushed 
    12ed28a7acb7: Image successfully pushed 
    44c4bb92fa11: Image successfully pushed 
    930cb2a860f7: Image successfully pushed 
    fff2c21b0a71: Image successfully pushed 
    b7b7ca7a9172: Image successfully pushed 
    a1bc79a43c77: Image successfully pushed 
    d46fdd618d55: Image successfully pushed 
    8988c8cbc051: Image successfully pushed 
    d989008d1f84: Image successfully pushed 
    Pushing tag for rev [d989008d1f84] on {https://cdn-registry-1.docker.io/v1/repositories/arungupta/wildfly-centos/tags/latest}
  • 您可以通过拉动图像来验证这一点:
    wildfly-centos> docker pull arungupta/wildfly-centos
    Pulling repository arungupta/wildfly-centos
    d989008d1f84: Download complete 
    511136ea3c5a: Download complete 
    5b12ef8fd570: Download complete 
    ae0c2d0bdc10: Download complete 
    e490dfcb3685: Download complete 
    f212cb9dbcf5: Download complete 
    28b11e6151f0: Download complete 
    73603eab89b7: Download complete 
    9a661ae4341b: Download complete 
    6265153611c7: Download complete 
    12ed28a7acb7: Download complete 
    44c4bb92fa11: Download complete 
    930cb2a860f7: Download complete 
    fff2c21b0a71: Download complete 
    b7b7ca7a9172: Download complete 
    a1bc79a43c77: Download complete 
    d46fdd618d55: Download complete 
    8988c8cbc051: Download complete 
    Status: Image is up to date for arungupta/wildfly-centos:latest

请享用!

翻译自: https://www.javacodegeeks.com/2014/12/pushing-docker-images-to-registry.html

你可能感兴趣的:(将Docker映像推送到注册表)