Setting up a private index/registry
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
localhost
hostname or the IP address127.0.0.1
and the registry port5000
using 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...