Docker – Private Registries
In this article, we will look into the Docker Registry. We will also look into steps on how to create and maintain your own Private Docker Registry. It is recommended to look into the basics of Docker if you are new.
What is Docker Registry?
Docker registry is your own private repository where you can store your own Docker images and share with others. Docker Registry is basically organized into Docker Repositories. Within the docker Repository, you can maintain specific versions of a Docker Image. DockerHub is the public repository for pulling the docker images. DockerHub is a public repository where anyone can pull the images which are stored in DockerHub.
Follow the below steps to setup docker registry:
Step 1: Pull Docker registry image using the below request:
$ docker pull registry
This command will pull the docker latest image from the docker registry
Step 2: Configure and run the docker registry image using the below command:
$ docker run -d -p 5000:5000 --name localregistry registry
This command will start the docker container registry on localhost port 5000. The base image used is the registry. The localregistry will be the container name.
Now we will also look into how you can pull, push and delete images from localregistry container. When the localregistry container is pushed successfully, it will return the container ID in the console.
You can verify by running the below command:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 25a66bd4219f registry "/entrypoint.sh /etc…" 10 seconds ago Up 9 seconds 0.0.0.0:5000->5000/tcp, :::5000->5000/tcp localregistry
Step 3: Pull images from DockerHub.
Let’s try to pull some images from DockerHub and push them to your docker private registry. For demonstration, let’s one version of the Ubuntu image and the latest Nginx server image.
Step 4: Tag the images which were pulled from DockerHub.
- localhost:5000 -> host for your docker private registry
- ubuntu: repository name
- 18.04: tag to identify the version
Step 5: Push the tagged images to your docker private registry.
Step 6: Pull the docker nginx image from the private docker registry. We are here pulling the docker image of Nginx: latest hosted at private registry i.e at localhost:5000