• docker镜像之registry


    1、如何使用docker-hub来pull和push镜像?

    root@richardo-docker01:~# docker login -u qwx619766
    Password:
    WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
    Configure a credential helper to remove this warning. See
    https://docs.docker.com/engine/reference/commandline/login/#credentials-store
    
    Login Succeeded
    root@richardo-docker01:~# docker tag httpd qwx619766/httpd:v1
    root@richardo-docker01:~# docker images qwx619766/httpd:v1
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    qwx619766/httpd     v1                  3dd970e6b110        4 weeks ago         138MB
    root@richardo-docker01:~# docker push qwx619766/httpd:v1
    

    2、如何使用本地的registry?

    # 上传和下载
    
    root@richardo-docker01:~# docker run -d -p 5000:5000 -v /myregistry:/var/lib/registry registry:2
    Unable to find image 'registry:2' locally
    2: Pulling from library/registry
    cbdbe7a5bc2a: Pull complete
    47112e65547d: Pull complete
    46bcb632e506: Pull complete
    c1cc712bcecd: Pull complete
    3db6272dcbfa: Pull complete
    Digest: sha256:8be26f81ffea54106bae012c6f349df70f4d5e7e2ec01b143c46e2c03b9e551d
    Status: Downloaded newer image for registry:2
    741390e28eb441115f64114ccbc092f5567b7195164d733b34056cde0e8f6eaa
    root@richardo-docker01:~# docker tag qwx619766/httpd:v1 127.0.0.1:5000/qwx619766/httpd:v1
    root@richardo-docker01:~# docker push 127.0.0.1:5000/qwx619766/httpd:v1
    The push refers to repository [127.0.0.1:5000/qwx619766/httpd]
    850c0c904ff3: Pushed
    c264370aa736: Pushed
    e6f7f192bbc8: Pushed
    6d80bc0bd923: Pushed
    d0fe97fa8b8c: Pushed
    v1: digest: sha256:60b82a0c2599b217d5231d3a54eb9f691ac8bc15b66f8f5f79f383f87c9c51ce size: 1366
    root@richardo-docker01:~# docker pull 127.0.0.1:5000/qwx619766/httpd:v1
    v1: Pulling from qwx619766/httpd
    Digest: sha256:60b82a0c2599b217d5231d3a54eb9f691ac8bc15b66f8f5f79f383f87c9c51ce
    Status: Image is up to date for 127.0.0.1:5000/qwx619766/httpd:v1
    127.0.0.1:5000/qwx619766/httpd:v1
    # 查看本地registry所有的镜像
    root@richardo-docker01:~# curl 127.0.0.1:5000/v2/_catalog
    {"repositories":["qwx619766/httpd"]}
    

    3、docker怎么删除本地的镜像?

    root@richardo-docker01:~# docker images
    REPOSITORY                     TAG                 IMAGE ID            CREATED             SIZE
    entrypoint-image               latest              18ed25a11432        5 hours ago         215MB
    cmd-image                      latest              69028b7e9882        5 hours ago         215MB
    my-image                       latest              1e0fcff0c90e        6 hours ago         1.23MB
    qwx619766/my-image             v1                  1e0fcff0c90e        6 hours ago         1.23MB
    <none>                         <none>              aa9a6f2c7f13        6 hours ago         1.23MB
    centos-with-vim-dockerfile-3   latest              f41e704ce73b        7 hours ago         272MB
    centos-with-vim-dockerfile-2   latest              fa86e8214b98        2 days ago          272MB
    centos-with-vim-dockerfile     latest              e99684eeca8a        2 days ago          272MB
    centos-with-vim                latest              0ec55bc57a3d        3 days ago          272MB
    busybox                        latest              f0b02e9d092d        4 weeks ago         1.23MB
    qwx619766/httpd                v1                  3dd970e6b110        4 weeks ago         138MB
    httpd                          latest              3dd970e6b110        4 weeks ago         138MB
    centos                         latest              0d120b6ccaa8        3 months ago        215MB
    registry                       2                   2d4f4b5309b1        5 months ago        26.2MB
    hello-world                    latest              bf756fb1ae65        10 months ago       13.3kB
    root@richardo-docker01:~# docker ps -a
    CONTAINER ID        IMAGE               COMMAND                   CREATED             STATUS                     PORTS                    NAMES
    741390e28eb4        registry:2          "/entrypoint.sh /etc…"    20 minutes ago      Up 20 minutes              0.0.0.0:5000->5000/tcp   naughty_noether
    2c3d4272e19e        entrypoint-image    "/bin/echo hello Ric…"    5 hours ago         Exited (0) 5 hours ago                              hungry_elgamal
    f1e3bd9b1838        entrypoint-image    "/bin/echo hello wor…"    5 hours ago         Exited (0) 5 hours ago                              thirsty_ganguly
    c86da0237cd7        cmd-image           "/bin/bash"               5 hours ago         Exited (0) 5 hours ago                              magical_lumiere
    223de519ab6c        cmd-image           "/bin/sh -c 'echo "h…"   5 hours ago         Exited (0) 5 hours ago                              crazy_banzai
    4aafcc8a6c9c        my-image            "sh"                      6 hours ago         Exited (0) 6 hours ago                              affectionate_wozniak
    70da6bf60009        aa9a6f2c7f13        "sh"                      6 hours ago         Exited (127) 6 hours ago                            strange_lichterman
    feb6c159c54e        aa9a6f2c7f13        "/bin/sh -c '/bin/ba…"    6 hours ago         Exited (127) 6 hours ago                            friendly_shtern
    6cf2ba54a949        0d120b6ccaa8        "/bin/sh -c 'yum upd…"    2 days ago          Exited (1) 2 days ago                               hardcore_shamir
    93ed0d03cfd0        centos-with-vim     "/bin/bash"               3 days ago          Exited (0) 3 days ago                               gifted_driscoll
    6a01b61ba5ac        centos              "/bin/bash"               3 days ago          Exited (0) 3 days ago                               naughty_galileo
    68fc6d293ee4        centos              "/bin/bash"               3 days ago          Exited (127) 3 days ago                             quirky_snyder
    94deef9a483a        hello-world         "/hello"                  3 days ago          Exited (0) 3 days ago                               pedantic_rubin
    c659711f5d56        httpd               "httpd-foreground"        3 days ago          Exited (255) 3 days ago    0.0.0.0:80->80/tcp       competent_heyrovsky
    root@richardo-docker01:~# docker rmi aa9a6f2c7f13
    Error response from daemon: conflict: unable to delete aa9a6f2c7f13 (must be forced) - image is being used by stopped container 70da6bf60009
    root@richardo-docker01:~# docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
    741390e28eb4        registry:2          "/entrypoint.sh /etc…"   21 minutes ago      Up 21 minutes       0.0.0.0:5000->5000/tcp   naughty_noether
    root@richardo-docker01:~# docker rm 70da6bf60009
    70da6bf60009
    root@richardo-docker01:~# docker rmi aa9a6f2c7f13
    Error response from daemon: conflict: unable to delete aa9a6f2c7f13 (must be forced) - image is being used by stopped container feb6c159c54e
    root@richardo-docker01:~# docker rm feb6c159c54e
    feb6c159c54e
    root@richardo-docker01:~# docer rmi aa9a6f2c7f13
    
    Command 'docer' not found, did you mean:
    
      command 'docker' from deb docker.io
    
    Try: apt install <deb name>
    
    root@richardo-docker01:~# docker rmi aa9a6f2c7f13
    Deleted: sha256:aa9a6f2c7f13004820f58f4695249582c0f2e2c0d80c94fb41fc8518a9045299
    Deleted: sha256:04c0fe73588b5a40273498876e96de0575562aef464370bedce6cf6e3e928f35
    root@richardo-docker01:~# docker images
    REPOSITORY                     TAG                 IMAGE ID            CREATED             SIZE
    entrypoint-image               latest              18ed25a11432        5 hours ago         215MB
    cmd-image                      latest              69028b7e9882        5 hours ago         215MB
    my-image                       latest              1e0fcff0c90e        6 hours ago         1.23MB
    qwx619766/my-image             v1                  1e0fcff0c90e        6 hours ago         1.23MB
    centos-with-vim-dockerfile-3   latest              f41e704ce73b        7 hours ago         272MB
    centos-with-vim-dockerfile-2   latest              fa86e8214b98        2 days ago          272MB
    centos-with-vim-dockerfile     latest              e99684eeca8a        2 days ago          272MB
    centos-with-vim                latest              0ec55bc57a3d        3 days ago          272MB
    busybox                        latest              f0b02e9d092d        4 weeks ago         1.23MB
    httpd                          latest              3dd970e6b110        4 weeks ago         138MB
    qwx619766/httpd                v1                  3dd970e6b110        4 weeks ago         138MB
    centos                         latest              0d120b6ccaa8        3 months ago        215MB
    registry                       2                   2d4f4b5309b1        5 months ago        26.2MB
    hello-world                    latest              bf756fb1ae65        10 months ago       13.3kB
    
  • 相关阅读:
    C# 如何在PDF文档中创建表格
    C# 如何创建Excel多级分组
    C# 添加、修改以及删除Excel迷你图表的方法
    C# 创建EXCEL图表并保存为图片
    【BZOJ5287】[HNOI2018]毒瘤(动态规划,容斥)
    【BZOJ5250】[九省联考2018]秘密袭击(动态规划)
    【BZOJ5213】[ZJOI2018]迷宫(神仙题)
    CodeForces Global Round 1
    【BZOJ5212】[ZJOI2018]历史(Link-Cut Tree)
    【BZOJ5211】[ZJOI2018]线图(树哈希,动态规划)
  • 原文地址:https://www.cnblogs.com/Richardo-M-Q/p/13985732.html
Copyright © 2020-2023  润新知