Related Articles

Related Articles

Creating a Private Repository and Push an Image to That Private Repository
  • Last Updated : 16 Oct, 2020

In this article, we show how to create a docker hub account and pull the image from the docker hub repository and pushing our image to the docker hub repository. As docker hub is a public repository that can be accessed by anyone so one can create their own private repository to which they can push and pull their image. For this, there is a registry container from the docker itself.

Requirements

  • Installed docker software in your respective operating system.
  • A pulled image in your docker container which you want to push into your private repository.

Steps to create a private repository and push and pull the image:

Step 1:The first step is to use the docker run command to download the private registry.

sudo docker -d -p 5000:5000 --name registry registry:2

Description of commands:

  • -d: This option is used to run the container in detached mode i.e the container can run in the background.
  • -p: This option is used to map our port number with 5000 port numbers on our localhost.
  • registry: It is a container provided by docker to host our private repositories.
  • 2: It is a tag to a registry to differentiate on the docker host.

download private repositry

You can use the docker ps command to see the running registry container.



sudo docker ps

repositry detail

Step 2: In this step, we are going to tag our existing image so that we can push that image to our local repository. 

sudo docker tag image_id tag_name

Description of commands:

  • image_id: The id of the image you want to push to your private repository.
  • tag_name: The name you want to give to your tag.

localhost

Step 3: We have tagged our image now it is ready to push to the private repository.

sudo docker push tag_name

tagging

Step 4: Now delete the local images so that we can pull it from a private repository. To delete the image use rmi command.

sudo rmi image_id

rmi

Step 5: In the previous step, we have deleted all the images now we pull the image from the private repository by docker pull command.

sudo docker pull image_tag

pull

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :