zoukankan      html  css  js  c++  java
  • docker registry 私有仓库 安装配置、查询、删除

    #++++++++++++++++++++++++++++++
    #docker-registry 私有仓库
    #搜索,下载register镜像
    docker search registry
    docker pull registry
    docker images
    #创建容器registry
    mkdir -p /www/docker/registry
    docker run --name registry --restart=always -p 5000:5000 
      -v /www/docker/registry:/var/lib/registry -d registry
    docker ps -l
    #镜像仓库地址使用域名
    echo '127.0.0.1  hub.test.com'>>/etc/hosts
    #修改tag (以hello-world为例)
    docker push hello-world
    docker tag  hello-world  hub.test.com:5000/hello-world:1.0
    #上传、删除、再下载镜像,删除后能下载成功
    docker images
    docker push  hub.test.com:5000/hello-world:1.0
    docker rmi hub.test.com:5000/hello-world:1.0
    docker images
    docker pull  hub.test.com:5000/hello-world:1.0
    docker images
    #查看仓库镜像
    curl hub.test.com:5000/v2/_catalog
    #++++++++++++++++++++++++++++++
    #registry开启删除
    #查看默认配置
    docker exec -it  registry sh -c 'cat /etc/docker/registry/config.yml'
    #开启删除(添加  delete: enabled: true)
    docker exec -it  registry sh -c "sed -i '/storage:/a  delete:' /etc/docker/registry/config.yml"
    docker exec -it  registry sh -c "sed -i '/delete:/a    enabled: true' /etc/docker/registry/config.yml"
    #重启
    docker restart registry
    #查询、删除镜像
    #查询镜像
    curl  <仓库地址>/v2/_catalog
    
    #查询镜像tag(版本)
    curl  <仓库地址>/v2/<镜像名>/tags/list
    
    #删除镜像API
    curl -I -X DELETE "<仓库地址>/v2/<镜像名>/manifests/<镜像digest_hash>"
    
    #获取镜像digest_hash
    curl  <仓库地址>/v2/<镜像名>/manifests/<tag> 
        --header "Accept: application/vnd.docker.distribution.manifest.v2+json"
        
        
    # 为方面使用,写了个shell脚本
    #详情 http://www.cnblogs.com/elvi/p/8384675.html
    #默认查询 -h #帮助 -d #删除
    #++++++++++++++++++++++++++++++
    #没配置https,非本机,需要配置安全地址才能使用
    #docker私有仓库设置(hub.test.com:5000替换为自己的地址)
    SetOPTS=" --insecure-registry hub.test.com:5000"
    sed  -i "s#^ExecStart.*#& $SetOPTS #" /usr/lib/systemd/system/docker.service
    grep 'ExecStart' /usr/lib/systemd/system/docker.service
    #重启docker
    systemctl daemon-reload
    systemctl restart docker
    #++++++++++++++++++++++++++++++
  • 相关阅读:
    2019.2.18接口
    第一阶段复习
    vue-cli使用介绍
    Webpack 入门教程
    js报错Uncaught TypeError: Cannot read property 'getElementsByTagName' of null
    用shell编程.编写一个程序,用循环创建多个目录 并在该目录下创建多个文件 在文件中写入内容:
    explorer.exe应用程序错误,怎么解决?
    [Java连接MySQL数据库——含详细步骤和代码](https://www.cnblogs.com/town123/p/8336244.html)
    墨刀的简单使用
    laravel报错:SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY...
  • 原文地址:https://www.cnblogs.com/kcxg/p/10760829.html
Copyright © 2011-2022 走看看