You want to push a new image to Google Container Registry (GCR) or pull an existing image from GCR.
Pushing a New Image to GCR
Prepare your Dockerfile.
FROM alpine:3.7 # some content...
Create an image and tag it with a path pointing to GCR within a project.
There are several variations of GCR’s hostname (ex:
eu.gcr.io, etc) depending on the data center’s location.
The GCR path has the following format:
docker build -t gcr.io/shitty-project/shitty-repo .
Log into GCP.
gcloud auth login
gcloud as a Docker credential helper.
gcloud auth configure-docker
Push the image to GCR.
docker push gcr.io/shitty-project/shitty-repo
View pushed image.
gcloud container images list-tags gcr.io/shitty-project/shitty-repo DIGEST TAGS TIMESTAMP 78b36c0b456d latest 2019-03-07T16:19:53
The repository and image can also be viewed in GCP Console.
Pulling an Existing Image from GCR
Proceed with the authentication process if it is not done already.
gcloud auth login gcloud auth configure-docker
Pull the image from GCR.
docker pull gcr.io/shitty-project/shitty-repo