[英]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访问注册表计算机。
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.