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
.
To push an image to Docker Hub, you must first name your local image using your Docker Hub username and the repository name that you created through Docker Hub on the web. You can add multiple images to a repository by adding a specific :<tag> to them (for example docs/base:testing ).
Run docker build -t <your_username>/my-private-repo . to build your Docker image. Run docker run <your_username>/my-private-repo to test your Docker image locally. You must be signed in to Docker Hub through Docker Desktop or the command line, and you must also name your images correctly, as per the above steps.
Docker Hub is a cloud-based repository in which Docker users and partners create, test, store and distribute container images.
In order to transfer a Docker image from one server to another, what you need to do is first export the image to a file, then copy that file over from your current server to the new one using scp or rsync and finally load the image to your new server.
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
.
Macos Use the command
$ docker pull NAME:tag $ docker tag NAME:tag myaccount/name:tag $ docker login # yourname # password $ docker push myaccount/name:tag
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With