{"id":8215,"date":"2021-10-05T16:56:30","date_gmt":"2021-10-05T11:26:30","guid":{"rendered":"https:\/\/www.skynats.com\/?p=8215"},"modified":"2026-03-17T10:44:26","modified_gmt":"2026-03-17T05:14:26","slug":"how-to-push-and-pull-images-from-docker-hub","status":"publish","type":"post","link":"https:\/\/www.skynats.com\/blog\/how-to-push-and-pull-images-from-docker-hub\/","title":{"rendered":"How to push and pull images from Docker Hub"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Docker Hub is a cloud-based library and community for container images, where we can find official images like Nginx, MongoDB, PostgreSQL, etc. Docker Hub seamlessly ships any application anywhere. So that we have to build the docker image and push it to the Docker registry and it will be available for anybody if you make it public.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But if the requirement is to keep the docker image private, so that it could only be shared with a specific group or team, that is also feasible. We can collaborate and build with our team, create and manage users and grant access to our repository and automate deployment with the production pipeline.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The ability to share container images on the Docker hub registry allows users to quickly share and build images. In this write-up, we will see how to use this feature.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create an AMI Docker AWS EC2 instance<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">login into the EC2 instance<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo su\n# yum update -y<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To configure docker we need to install the docker package<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># yum install docker docker-distribution -y<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To start the docker engine<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># service docker start<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To run a pre-existing docker image<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker run -it ubuntu\n:\/# ls<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Create a file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:\/# touch myproject\n:\/#exit<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To list docker images<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker images<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To list details of running containers like ID, name, image<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker ps -a<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To create an image of a container<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker commit NAME New_image_name<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To push images to Docker Hub we should have an account in Docker Hub. To signup in Docker Hub<br>Link is<br>https:\/\/hub.docker.com\/<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Docker_ID: username<br>email:-<br>password:-<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To login into docker hub<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker login --&gt; username --&gt; password<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To tag the docker image and push the image to the docker hub we have to specify the docker hub username to<br>Upload image to the specific repository under docker hub user.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker tag New_image_name\nusername\/project_name<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To share a local docker image to docker hub<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker push username\/project_name<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The registry has several repositories and a repository has many different versions of the same image which are individually tagged.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To permit acces to specific team on repository &#8211;&gt; click on image &#8211;&gt; setting &#8211;&gt; make private &#8211;&gt; name <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create another EC2 instance<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo su<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># yum update &amp;&amp; yum install docker -y &amp;&amp; service docker start\n# docker images<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To login into docker hub<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker login --&gt; username --&gt; password<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To pull image from docker hub<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker pull username\/project_name\n# docker images<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To create a container using image<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker run -it \u2013name container_name username\/project_name binbash\n:\/# ls\n:\/# exit<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"> To delete images<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker rmi -f $(docker image -q)\n# docker images<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-why-use-docker-hub\">Why use Docker Hub?<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Features that enable continuous integration and continuous delivery.<\/li>\n\n\n\n<li>Docker hub supports GitHub, automated tests, and webhooks.<\/li>\n\n\n\n<li>Currently, docker hub offers unlimited public repositories and one private repository with up to 3 collaborations.<\/li>\n\n\n\n<li>A plethora of docker certified and verified official pre-built images exists in docker hub public registry.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Finding it difficult? Contact our <span style=\"color:#0070a0\" class=\"has-inline-color\"><a href=\"https:\/\/www.skynats.com\/devops-support\" type=\"link\" id=\"https:\/\/www.skynats.com\/devops-support\" target=\"_blank\" rel=\"noreferrer noopener\">DevOps support team<\/a><\/span>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Docker Hub is a cloud-based library and community for container images, where we can find official images like Nginx, MongoDB, PostgreSQL, etc. Docker Hub seamlessly ships any application anywhere. So that we have to build the docker image and push it to the Docker registry and it will be available for anybody if you make [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,127],"tags":[607,606],"class_list":["post-8215","post","type-post","status-publish","format-standard","hentry","category-blog","category-docker","tag-pull-docker-image","tag-push-docker-image"],"_links":{"self":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/8215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/comments?post=8215"}],"version-history":[{"count":1,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/8215\/revisions"}],"predecessor-version":[{"id":17459,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/8215\/revisions\/17459"}],"wp:attachment":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/media?parent=8215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/categories?post=8215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/tags?post=8215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}