Manage your Docker images

Trevor
2 min readMar 23, 2020

In this article, I assume you have prior knowledge about creating a Docker image of whichever language, framework or tool you are working with. For-instance in my previous article, where I built a Docker image of the Angular app then deploying to Google Cloud Kubernetes: see the article here …

In this article, we discuss pushing (for storage) and pulling to your local docker repository/ machine. Today, we work with Docker Hub and Google Cloud Registry(gcr)

Pulling

  • From docker hub: the command can be copied from the repo of the desired image on docker hub
$ docker pull <name_of_the_image>
  • From gcr: the command can be too copied from the image upon hovering over the image, copy field is provided.
$ docker pull [HOSTNAME]/[PROJECT-ID]/[IMAGE]:[TAG]
e.g
docker pull grc.io/my-project-1234/angular-docker@sha256:92dbf946...

Pushing

  • For docker hub: You need to add your dockerHub username & password locally: Run this on your terminal
$ docker login -u [username] -p [password] docker.io

Then tag your desired image as follows:

$ docker tag [image-id] [dockerhub-username]/[image-name]
e.g
docker tag 7b5bff83a250 trevornathan/angular-docker

When your list again, your images: you will notice that your docker hub username has attached to the image name. This is what we push, run:

$ docker push [tagged-image]
  • For GCR: You also need to tag the desired image. On your Cloud Console, select the project your working on & copy the project ID
$ docker tag [image-name] gcr.io/[project-id]/[gcr-repo-name]

Then let's push, first confirm that your image has been tagged:
However, the next step we use gcloud command, therefore I assume you have you cloud SDK configured to your project, run this to confirm:

$ gcloud info

then can now push:

$ gcloud docker -- push [tagged-image]

Above is the screenshot of my container Registry and my image is listed.
When you modify the image and re-push, it will be tagged as the latest. You can still change the tags to your convenient naming. eg v1.0, v1.2, v1.3 etc.

--

--

Trevor

👨‍💻 Cloud Geek | 👨‍🏫Educator #GCP | Mentor @gdsc_uganda | Facilitator @GDGCloudKampala | Ex-Lead #DeveloperStudentClubs | #Mindfulness 🧘🏽‍♂️