简体   繁体   中英

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.

I have access to the registry machine via SSH.

Question

How can I push all my registry images to hub.docker.com?

I think that the only way is to pull them all, then retag them and push to 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 .

@zigarn script automates this job.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM