Setting Up A Private Indexregistry
Earlier, we used a Docker-hosted registry (https://hub.docker.com) to push and pull images. Nonetheless, quite often you will come across use cases where you will have to host a private registry in your infrastructure. In this recipe, we will host our own private registry using Docker’s registry:2 image.
Getting ready
Make sure that Docker daemon version 1.6.0 or above is running on the host.
How to do it…
Perform the following steps:
- Let’s begin by launching a local registry on the container using the following command:
$ docker container run -d -p 5000:5000 \
--name registry registry:2
- To push the image to the local registry, you need to prefix the repository name with the
localhosthostname or the IP address127.0.0.1and the registry port5000using the Docker image tag command, as shown in the following code:
$ docker tag apache2 localhost:5000/apache2
Here, we will reuse the apache2 image we built in the previous recipe.
- Now, let’s push the image to the local registry using the
docker image pushcommand, as shown in the following screenshot:

How it works…
The preceding command to pull the image will download the official registry image from Docker Hub and run it on port 5000 . The -p option publishes the container port to the host system’s port. We will explore details about port publishing in the next chapter.
There’s more…
The registry has a notification framework that can invoke WebHooks when it receives a push or pull request. These WebHooks can be chained with your DevOps flow.
See also
-
The documentation on GitHub: