简体   繁体   English

如何将映像从私有注册表推送到hub.docker.com?

[英]How to push image from private registry to hub.docker.com?

I'm migrating a project from a private registry to hub.docker.com but I don't have all tagged image on computer. 我正在将项目从私有注册表迁移到hub.docker.com,但我在计算机上没有所有带标签的图像。

I have access to the registry machine via SSH. 我可以通过SSH访问注册表计算机。

Question

How can I push all my registry images to hub.docker.com? 如何将所有注册表映像推送到hub.docker.com?

I think that the only way is to pull them all, then retag them and push to hub.docker.com 我认为唯一的方法是将它们全部拉出,然后重新标记它们并推送到hub.docker.com

You can script it with something like: 您可以使用类似以下内容的脚本:

for repository in $(curl -s http://localhost:5000/v2/_catalog | jq -r '.repositories[]'); do
  for image in $(curl -s http://localhost:5000/v2/${repository}/tags/list | jq -r '(.name + ":" + .tags[])')
    docker image pull localhost:5000/${image}
    docker image tag localhost:5000/${image} <YOUR_HUB_PREFIX>/${image}
    docker image push <YOUR_HUB_PREFIX>/${image}
    # if you need some cleanup
    docker image rm localhost:5000/${image} <YOUR_HUB_PREFIX>/${image}
  done
done

Access to your registry machine via SSH, use docker login to login inside your Docker Hub account, add a tag to your images which points to Docker Hub docker tag my_own_registry.com/image:tag user/image:tag a then push that new tag using docker push user/image:tag . 通过SSH访问您的注册表计算机,使用docker login在您的Docker Hub帐户中登录,在图像中添加一个标签,该标签指向Docker Hub docker tag my_own_registry.com/image:tag user/image:tag一个然后推送该新标签使用docker push user/image:tag

@zigarn script automates this job. @zigarn脚本可自动完成此工作。

Edit: You commented that your bandwith is bad, then you can access via ssh to your registry machine, save your image using docker save , then copy it to your machine and load it by docker load and finally push it to Docker Hub as explained above. 编辑:您评论说带宽不好,然后您可以通过ssh访问注册表计算机,使用docker save保存图像,然后将其复制到计算机并通过docker load加载它,最后将其推送到Docker Hub,如上所述。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将图像推送到 hub.docker.com 而不是 docker.io - How to push image to hub.docker.com instead of docker.io 来自 hub.docker.com 的 Docker 镜像统计信息 - Docker image statistics from hub.docker.com Bitbucket 找不到来自集线器的图像。docker.com - Bitbucket cannot found image from hub.docker.com 如何恢复我对 hub.docker.com 的最后一次推送? - How can I revert my last push on hub.docker.com? query a docker registry (hub.docker.com) using go docker client without docker daemon dependency - query a docker registry (hub.docker.com) using go docker client without docker daemon dependency 如何将Docker映像从Docker Hub私有注册表中拉到Azure容器服务(ACS)中? - How to pull docker image from docker hub private registry into Azure Container Service (ACS)? 无法将映像推送到Docker Hub注册表 - Unable to push image to Docker Hub registry docker 从集线器拒绝请求对资源的访问。docker.com - docker pull requested access to the resource is denied from hub.docker.com hub.docker.com和dockerheart.com有什么区别 - What is the difference between hub.docker.com and dockerheart.com 如何从一个私有注册表中提取 Docker 映像并将其推送到 Jenkins 管道中的第二个不同的私有注册表 - How do I pull a Docker image from one private registry and push it to a second different private registry in Jenkins pipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM