Pages

Sunday, February 19, 2017

Docker - playing with Registries



A docker registry can be taught as place to store and distribute Docker images. It serves as a target for your docker push and docker pull commands.

Docker registries is a service that store docker images in a way that is layer aware.In this article we will see how we can create a docker image , commit it docker hub and use the docker hub to transfer the image to another location. In this article we will work using commands like pull,push ,login commit and log out.

Docker provides a free public registry called docker hub “docker.io”. Sign up the free account and we can use those from our local machine to pull and push the images

1. Login to the docker hub from your local machine using the “docker login” command as,
[puppet@root$:~]$  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: jagadesh1982
Password:
Login Succeeded

2. Start a docker container
[root@localhost ~]# docker run -dit ssh-ubuntu:v0.1
b0d45fc63c6ea512ce7abf646ebc0c10faac9a213777df0b84567a8190a6566c

3.Commit the started container to named image using the commit command
[root@localhost ~]# docker commit b0d45fc63c6e jagadesh1982/docker-ssh-ubuntu
sha256:24a28b5a880a8da64c8dc06a8a70a232985a0b81c4ae0577fa308a4da28d3a9a

Make sure that the image being committed is given a name jagadesh1982/docker-ssh-ubuntu

4. Push the docker image to the docker hub
[root@localhost ~]# docker push jagadesh1982/docker-ssh-ubuntu
The push refers to a repository [docker.io/jagadesh1982/docker-ssh-ubuntu]
f424ab7bccf1: Pushed
5eb5bd4c5014: Pushed
d195a7a18c70: Pushed
af605e724c5a: Pushed
59f161c3069d: Pushed
4f03495a4d7d: Mounted from library/ubuntu
latest: digest: sha256:7adcbca38458c525bc972e77588928ad2aabd40e81bf209ca403d026112299e1 size: 1569

5. Remove the local docker image jagadesh1982/docker-ssh-ubuntu
[puppet@root$:~]$  docker rmi jagadesh1982/docker-ssh-ubuntu

6. Now pull the docker image jagadesh1982/docker-ssh-ubuntu” which will download the image from the docker hub
[puppet@root$:~]$  docker pull jagadesh1982/docker-ssh-ubuntu
Using default tag: latest
Trying to pull repository docker.io/jagadesh1982/docker-ssh-ubuntu ...
latest: Pulling from docker.io/jagadesh1982/docker-ssh-ubuntu
8aec416115fd: Already exists
695f074e24e3: Already exists
946d6c48c2a7: Already exists
bc7277e579f0: Already exists
2508cbcde94b: Already exists
f274ef5fcd9a: Already exists
a5268b86b65e: Already exists
Digest: sha256:2f6ddb28b1403b7ddf370c87f16d4ce495030e8819191e8f68e68dc476a7ad65

7. Logout from the docker hub
[root@localhost ~]# docker logout

Remove login credentials for https://index.docker.io/v1/

No comments :

Post a Comment