zoukankan      html  css  js  c++  java
  • docker 创建自己的镜像仓库


    root@Yzz:/home/yindongzi# docker run -d -p 5001:5000 -v /usr/local/registry:/var/lib/registry --restart=always --name registry registry:2 97469284c8d735919f78e225c1c78a8d8aa714fa878c308e03e40d4fdacc0d03 root@Yzz:/home/yindongzi# curl http://localhost:5001/v2/_catalog {"repositories":[]} root@Yzz:/home/yindongzi# docker pull busybox Using default tag: latest latest: Pulling from library/busybox bdbbaa22dec6: Pull complete Digest: sha256:6915be4043561d64e0ab0f8f098dc2ac48e077fe23f488ac24b665166898115a Status: Downloaded newer image for busybox:latest docker.io/library/busybox:latest
    root@Yzz:/home/yindongzi# docker images|grep busybox busybox latest 6d5fcfe5ff17 7 weeks ago 1.22MB
    #名称一定要修改掉,不然直接push是不成功的
    root@Yzz:/home/yindongzi# docker tag busybox localhost:5001/busybox:v1.0


    root@Yzz:/home/yindongzi# docker images|grep busybox busybox latest 6d5fcfe5ff17 7 weeks ago 1.22MB localhost:5001/busybox v1.0 6d5fcfe5ff17 7 weeks ago 1.22MB root@Yzz:/home/yindongzi# docker push localhost:5001/busybox The push refers to repository [localhost:5001/busybox] 195be5f8be1d: Pushed v1.0: digest: sha256:edafc0a0fb057813850d1ba44014914ca02d671ae247107ca70c94db686e7de6 size: 527 root@Yzz:/home/yindongzi# curl http://localhost:5001/v2/_catalog {"repositories":["busybox"]}

     

    以上内容是将本地的仓库push到localhost:5001的registry,如果是push到目标IP,给不同的人push/pull,可以参考https://www.cnblogs.com/jpfss/p/10948256.html

    我这边传输的时候报错:Get https://192.168.43.111:5001/v2/: http: server gave HTTP response to HTTPS client

    root@Yzz:/etc/docker# docker tag busybox 192.168.43.111:5001/busybox_linux
    root@Yzz:/etc/docker# docker images
    REPOSITORY                          TAG                 IMAGE ID            CREATED             SIZE
    composetest_web                     latest              7dab0202c9dd        6 hours ago         222MB
    tomcat                              latest              aeea3708743f        6 days ago          529MB
    maven                               latest              e378090eb05d        11 days ago         638MB
    python                              3.7-alpine          a5d195bb2a63        12 days ago         97.8MB
    nginx                               latest              2073e0bcb60e        2 weeks ago         127MB
    mysql                               latest              791b6e40940c        2 weeks ago         465MB
    registry                            2                   708bc6af7e5e        3 weeks ago         25.8MB
    registry                            latest              708bc6af7e5e        3 weeks ago         25.8MB
    redis                               alpine              b68707e68547        4 weeks ago         29.8MB
    alpine                              latest              e7d92cdc71fe        4 weeks ago         5.59MB
    192.168.43.111:5001/busybox         v1.0                6d5fcfe5ff17        7 weeks ago         1.22MB
    192.168.43.111:5001/busybox_linux   latest              6d5fcfe5ff17        7 weeks ago         1.22MB
    busybox                             latest              6d5fcfe5ff17        7 weeks ago         1.22MB
    localhost:5001/busybox              v1.0                6d5fcfe5ff17        7 weeks ago         1.22MB
    hello-world                         latest              fce289e99eb9        13 months ago       1.84kB
    dockersamples/static-site           latest              f589ccde7957        3 years ago         191MB
    root@Yzz:/etc/docker# docker push 192.168.43.111:5001/busybox_linux
    The push refers to repository [192.168.43.111:5001/busybox_linux]
    Get https://192.168.43.111:5001/v2/: http: server gave HTTP response to HTTPS client
    

    解决办法参考:https://blog.csdn.net/u011085172/article/details/72303038

    root@Yzz:/home/yindongzi# cd /etc/docker
    root@Yzz:/etc/docker# ls
    key.json
    root@Yzz:/etc/docker# touch daemon.json
    root@Yzz:/etc/docker# vi daemon.json
    

      

    daemon.json 

    { "insecure-registries":["192.168.163.131:5000"]}
    

      

    重启之后push,就成功了

    root@Yzz:/etc/docker# service docker stop
     * Stopping Docker: docker                                                                                       [ OK ]
    root@Yzz:/etc/docker# service docker start
     * Starting Docker: docker                                                                                       [ OK ]
    root@Yzz:/etc/docker# docker push 192.168.43.111:5001/busybox_linux
    The push refers to repository [192.168.43.111:5001/busybox_linux]
    195be5f8be1d: Pushed
    latest: digest: sha256:edafc0a0fb057813850d1ba44014914ca02d671ae247107ca70c94db686e7de6 size: 527
    root@Yzz:/etc/docker#
    

    在目标机上可以查找到push过来的镜像

    PS D:dockerdoodlecheers2019> curl http://192.168.43.111:5001/v2/_catalog
    
    
    StatusCode        : 200
    StatusDescription : OK
    Content           : {"repositories":["busybox","busybox_linux"]}
    

      

      

     

  • 相关阅读:
    6. Flask请求和响应
    5. Flask模板
    FW:Software Testing
    What is the difference between modified duration, effective duration and duration?
    How to push master to QA branch in GIT
    FTPS Firewall
    Query performance optimization of Vertica
    (Forward)5 Public Speaking Tips That'll Prepare You for Any Interview
    (转)The remote certificate is invalid according to the validation procedure
    Change
  • 原文地址:https://www.cnblogs.com/zhizhiyin/p/12326651.html
Copyright © 2011-2022 走看看