Mar 4, 2023

Docker - working steps | Part-5 Manage Docker with Docker Hub

Create your own docker account. 

Your Docker ID becomes your user namespace for hosted Docker services, and becomes your username on the Docker forums. To create a new Docker ID: Go to the Docker Hub signup page. Enter a username that will become your Docker ID.

We can consider Docker Hub as a service from Docker for locating and distributing containers for each image within the specified team. It is the most comprehensive repository of container images, with an order of all content sources, including open-source projects, developing the sharing of the application source code, and community developers using containers.

Let us work with Docker and Docker hub:

-- find your images from your docker server

# docker images
REPOSITORY     TAG       IMAGE ID       CREATED       SIZE
demoimagevol   latest    44787e8aa6c0   5 days ago    77.8MB
ubuntu         latest    58db3edaf2be   5 weeks ago   77.8MB

-- create tag for one of image

docker tag <docker-host-imagename> <docker-hub-username>/<image-name>

e.g.,

# docker tag demoimagevol gmohapat/demoimagevol

# docker images
REPOSITORY              TAG       IMAGE ID       CREATED       SIZE
gmohapat/demoimagevol   latest    44787e8aa6c0   5 days ago    77.8MB
demoimagevol            latest    44787e8aa6c0   5 days ago    77.8MB
ubuntu                  latest    58db3edaf2be   5 weeks ago   77.8MB

-- login to docker hub from docker server

# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: gmohapat
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
#


-- Now push your docker image to docker hub

# docker push gmohapat/demoimagevol
Using default tag: latest
The push refers to repository [docker.io/gmohapat/demoimagevol]
c5ff2d88f679: Mounted from library/tomcat
latest: digest: sha256:681c232cd9bdd7f14b5f468271fcdcb4d0acd5f7fa7bb4f6167113662e3350e3 size: 529
#


Now login to docker hub and see.
Yes, I able to my docker image in docker hub.














-- Now pull the same image from docker hub to docker server.

before doing that you need to delete the image what is created now. with same name we can't keep two images.

# docker images
REPOSITORY              TAG       IMAGE ID       CREATED       SIZE
gmohapat/demoimagevol   latest    44787e8aa6c0   5 days ago    77.8MB
demoimagevol            latest    44787e8aa6c0   5 days ago    77.8MB
ubuntu                  latest    58db3edaf2be   5 weeks ago   77.8MB

# docker rmi -f 44787e8aa6c0
Untagged: gmohapat/demoimagevol:latest
Untagged: gmohapat/demoimagevol@sha256:681c232cd9bdd7f14b5f468271fcdcb4d0acd5f7fa7bb4f6167113662e3350e3
Untagged: demoimagevol:latest
Deleted: sha256:44787e8aa6c0882df2780cbd691d0b85c01a5a0f750dca40256686f38e1d71d8
Deleted: sha256:54317c9383d4ebe8087d3d77f7103dc612ae37cc8581f4fe7ffdd88920a75f8c

# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
ubuntu       latest    58db3edaf2be   5 weeks ago   77.8MB
#

-- Now pull the image from docker hub

# docker pull gmohapat/demoimagevol
Using default tag: latest
latest: Pulling from gmohapat/demoimagevol
10ac4908093d: Already exists
Digest: sha256:681c232cd9bdd7f14b5f468271fcdcb4d0acd5f7fa7bb4f6167113662e3350e3
Status: Downloaded newer image for gmohapat/demoimagevol:latest
docker.io/gmohapat/demoimagevol:latest
#

-- Now verify

# docker images
REPOSITORY              TAG       IMAGE ID       CREATED       SIZE
gmohapat/demoimagevol   latest    44787e8aa6c0   5 days ago    77.8MB
ubuntu                  latest    58db3edaf2be   5 weeks ago   77.8MB
#

Yes, we able to pull the image from our own docker hub account.

Test with your own risk:

-- start all docker containers at one go

# docker start $(docker ps -a)

-- stop all docker containers at one go

# docker stop $(docker ps -a)


1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete

Translate >>