Step 1 − Use the Docker run command to download the private registry. This should be possible by using the following command.
sudo docker run –d –p 5000:5000 –-name registry registry:2
The following points need to be noted about the above command − Registry is the container managed by Docker which can be used to host private repositories.
Step 2 −Let's do a docker ps to see that the registry container is indeed running.
We have now confirmed that the registry container is for sure running.
Step 3 − Now we should label one of our existing images with the goal that we can push it to our local repository. In our example, since we have the centos image available locally, we will tag it to our private repository and add a tag name of centos.
sudo docker tag 67591570dd29 localhost:5000/centos
The following points should be noted about the above command −
Step 4 − Now let's use the Docker push command to push the repository to our private repository.
Here, we are pushing the centos image to the private repository hosted at localhost:5000.
sudo docker push localhost:5000/centos
Step 5 − Now let's delete the local images we have for centos using the docker rmi commands. We can then download the required centos image from our private repository.
sudo docker rmi centos:latest sudo docker rmi 67591570dd29
Step 6 − Now that we don't have any centos images on our local machine, we can now utilize the following Docker pull command to pull the centos image from our private repository.
Here, we are pulling the centos image to the private repository hosted at localhost:5000.
sudo docker pull localhost:5000/centos