IoT Bytes

Bits and Bytes of IoT

Basics of Container Registry, Repository, Tags, and Docker Hub

Pradeep Singh | 15th Sep 2017

docker_registry

Docker Registry plays a key role in managing and sharing the Docker images. In this article, you will understand, what is the Docker Registry and how to use it.

1. What is Docker Registry?

The Registry is a stateless, highly scalable server-side application that stores and lets you distribute Docker images. The Registry is open-source, under the permissive Apache license.   – From Docker Documentation

If you are looking for a free-to-use, and zero maintenance Container Registry, try Docker Hub. It is a public Registry that lets you share container images with the co-workers, customers, or the Docker community at large.

However, if you want to have a tight control and fully own your container images, you can deploy your own registry server or explore the enterprise-grade Docker Truster Registry solution.

2. Relationship Between the Registry, Repository, and Tag:

As explained above, Registry allows you to store and share container images.

The Repository, on the other hand,  is a collection of related container images stored on a Registry Server. It usually provides different versions of the same application based on the image Tags. For example – mongodb, mysql, nginx etc could be different Repositories.

The Tag is an alphanumeric identifier attached to an image name (separated by a “:“) within a Repository. For example – ‘mongodb:1.1‘, ‘mongodb:test‘ are the image names in the ‘mongodb‘ registry with ‘1.1‘ and ‘test‘ as image tags respectively.

The following image would make it easy for you to visualize the relationship between the Registry, Repository, and Tags –

Registry

3. Docker Hub:

Docker Hub is a cloud-based registry service which allows you to link to code repositories, build your images and test them, stores manually pushed images, and links to Docker Cloud so you can deploy images to your hosts. – From Docker Documentation

Let’s try to upload and download images from Docker Hub (I am assuming you have Docker installed on your computer. If not please visit this Link) –

3.1 Register on Docker Hub to create your Docker ID.

3.2 Pull “alpine” Docker Image using “docker image pull alpine” (we are using alpine imager because of its small size). You can view local Docker Images using the “docker image ls” command.

3.3 Create the replica of “alpine” Docker image using “docker image tag SOURCE_IMAGE[:TAG] DOCKER_HUB_ID/TARGET_IMAGE[:TAG]” command. To upload the image you need to use your Docker Hub id with the new Image name. I would use this command to copy the “alpine” image  “docker image tag alpine:latest pradeesi/linux:1.0

3.4 Login to Docker Hub with you docker hub ID using the “docker login” command.

3.5 Push the Image to Docker Hub using the “docker image push DOCKER_HUB_ID/IMAGE_NAME:TAG” command. I would use “docker image push pradeesi/linux:1.0” command.

3.6 You can delete the image that you copied from “alpine” image using the “docker rmi IMAGE_NAME:TAG“. If you want you can delete all the local images using the “docker rmi -f $(docker images -q)“. After deleting the files you can list the images using the docker image ls” command.

3.7 Now you can pull the image back from your Docker Hub repository using the “docker image pull REPOSITORY_NAME/IMAGE_NAME:TAG” command. I would use “docker image pull pradeesi/linux:1.0” command. You can list the local images using the “docker image ls” command.

Following screenshot shows the console output for these steps –

Docker Registry

Following is the screenshot of the Docker Hub Repository we created with these steps –

DockerHub


 

References:

https://docs.docker.com/registry/

https://docs.docker.com/registry/deploying/

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: