How to Push Docker Images to GCR & Pull the same from GCR (Google Container Registry)

How to Push Docker Images to GCR & Pull the same from GCR (Google Container Registry)

We have various options available to Store/Manage our Container Images.

  • Docker Hub
  • GCR (Google Container Registry)
  • Amazon Elastic Container Registry (ECR)

All three have their own Pros and Cons.

Here we will deal with GCR (Google Container Registry) and we will see How we can push images to GCR and How we can pull images from GCR


Pre-requisites 1) Install Docker 2) Install Google Cloud SDK


  • Let's suppose we have some images available in our local computer. We can see using docker images command Docker Images.png We could see we have image 'node-app' available with tag 0.1

  • To push images to your private registry hosted by gcr, you need to tag the images with a registry name. The format is [hostname]/[project-id]/[image]:[tag].

For gcr: [hostname]= gcr.io

[project-id]= your project's ID

[image]= your image name

[tag]= any string tag of your choice. If unspecified, it defaults to "latest".

Docker Tag.png

Now, we see 2 images one is node-app:0.1 and other starting with gcr.io/project_name/node-app:0.1

  • Now time to push the Images to GCR, but before that we need to login to gcloud

gcloud auth login your_username

gcloud auth login.png

  • Then we need to set the Project.

gcloud config set project your_project_id

gcloud set project.png

  • Once all done,we are set to push the image to GCR.

Docker push .png

Verify in GCR

Container Registry Icon.png

  • Click on it, we will see the image which we have pushed

node-app in gcr.png

Images in GCR.png

  • To pull the stored image from GCR, use below command

carbon(1).png


Resources: googlecourses.qwiklabs.com - GSP055