Clone docker image to dockerhub account

12,909

Solution 1

Use docker tag ubuntu:latest myaccount/ubuntu:latest. (you should also tag with a specific version number so that you can still reference the image when you update :latest)

Then docker push myaccount/ubuntu.

It won't actually make a copy, but it will add the new tag to the existing image. Other people won't see the tag unless they docker pull myaccount/ubuntu.

Solution 2

Macos Use the command

$    docker pull NAME:tag
$    docker tag NAME:tag myaccount/name:tag
$    docker login
#    yourname
#    password
$    docker push myaccount/name:tag
Share:
12,909

Related videos on Youtube

sof
Author by

sof

Updated on June 04, 2022

Comments

  • sof
    sof almost 2 years

    Let's say one of the official docker base images ubuntu:latest and I have a dockerhub account myaccount. How to clone ubuntu:latest to myaccount's repository? The work flow can then be introduced as follows,

    $ docker pull myaccount/ubuntu:latest
    $ docker run -it myaccount/ubuntu:latest /bin/bash
    # root@mycontainer: apt-get install onepackage
    # root@mycontainer: exit
    $ docker commit mycontainer myaccount/ubuntu:latest-new
    $ docker push myaccount/ubuntu:latest-new
    

    I need push just the delta latest-new minus latest.

    • Tarun Lalwani
      Tarun Lalwani almost 7 years
      You should not make changes manually by going in container and then making changes and committing the image. This doesn't preserver the metadata changes. And your history won't show the changes. So always use a Dockefile to make changes on top of another image that you want to customize. Rest your main question is answered by @Andy
  • sof
    sof almost 10 years
    What I expect is that dockerhub can provide us with the analogical function of github fork.
  • sof
    sof almost 10 years
    Although what dockerhub does is more verbose that githhub fork, it satisfies delta push. Accepted.
  • sof
    sof almost 10 years
    Oh, it's just a tagged link. Will the target repository on dockerhub become broken if the linked source is removed by chance?
  • Andy
    Andy almost 10 years
    Empirically testing, it looks like deleting the source repository does not affect the image in the "aliased" repository. I believe this is because both are actually aliases and neither is considered the canonical source. The persistence of referent image in the Docker Registry seems independent of the tagged names/aliases. At least that's the current behavior.
  • Peter H. Boling
    Peter H. Boling over 2 years
    This doesn't answer the complete question, which includes adding a package to the cloned image. I have the same question, and nothing in this SO directly explains how to do that. It seems this writeup gives two methods for achieving the modification aspect: linuxhandbook.com/modifying-docker-image