Bird
Raised Fist0
GCPcloud~20 mins

Pushing and pulling images in GCP - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
GCR Image Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What happens when you push a Docker image to Google Container Registry?

You have built a Docker image locally and want to store it in Google Container Registry (GCR). What is the main result of pushing the image to GCR?

AThe image is uploaded and stored in GCR, making it available for other services to pull.
BThe image is converted to a virtual machine and deployed automatically.
CThe image is only stored temporarily and deleted after 24 hours.
DThe image is deleted from your local machine after upload.
Attempts:
2 left
💡 Hint

Think about what a registry does with images you push to it.

❓ Configuration
intermediate
2:00remaining
Which command correctly tags a local Docker image for pushing to GCR?

You have a local Docker image named my-app with tag v1. Your GCP project ID is my-project. Which command correctly tags the image for pushing to Google Container Registry?

Adocker tag gcr.io/my-project/my-app:v1 my-app:v1
Bdocker tag my-app gcr.io/my-project:v1/my-app
Cdocker tag my-app:v1 my-project/gcr.io/my-app:v1
Ddocker tag my-app:v1 gcr.io/my-project/my-app:v1
Attempts:
2 left
💡 Hint

Remember the format for GCR image names: gcr.io/[PROJECT-ID]/[IMAGE]:[TAG]

❓ Architecture
advanced
2:00remaining
What is the best architecture to securely pull images from GCR in a Kubernetes cluster?

You want your Kubernetes cluster to pull private images from Google Container Registry securely. Which architecture ensures secure and automated access?

AUse Kubernetes secrets with service account keys to authenticate image pulls.
BMake the images public in GCR so no authentication is needed.
CUse Workload Identity to allow Kubernetes service accounts to access GCR without storing keys.
DManually log in to GCR on each node using Docker credentials.
Attempts:
2 left
💡 Hint

Consider a method that avoids managing long-lived keys and automates authentication.

❓ service_behavior
advanced
2:00remaining
What happens if you try to pull a non-existent image tag from GCR?

You run docker pull gcr.io/my-project/my-app:nonexistent but the tag nonexistent does not exist in GCR. What is the expected behavior?

ADocker returns an error saying the image or tag was not found.
BDocker pulls the latest available tag instead automatically.
CDocker pulls an empty image with no layers.
DDocker pulls the image but with default configuration.
Attempts:
2 left
💡 Hint

Think about how Docker handles requests for images that do not exist.

❓ security
expert
2:00remaining
Which IAM role is required to allow a user to push images to Google Container Registry?

You want to grant a user permission to push Docker images to GCR in your project. Which IAM role should you assign?

Aroles/container.admin
Broles/storage.objectAdmin
Croles/storage.objectViewer
Droles/container.developer
Attempts:
2 left
💡 Hint

Consider which role allows writing objects to the underlying storage bucket used by GCR.

Practice

(1/5)
1. What does the docker push command do in Google Cloud Platform?
easy
A. Downloads a container image from Google Container Registry
B. Uploads your container image to Google Container Registry
C. Deletes a container image from your local machine
D. Builds a new container image from a Dockerfile

Solution

  1. Step 1: Understand the purpose of docker push

    The docker push command uploads your local container image to a remote registry like Google Container Registry.
  2. Step 2: Differentiate from other commands

    docker pull downloads images, docker build creates images, and deleting is a separate action.
  3. Final Answer:

    Uploads your container image to Google Container Registry -> Option B
  4. Quick Check:

    Push = Upload image to registry [OK]
Hint: Push means upload image to cloud registry [OK]
Common Mistakes:
  • Confusing push with pull
  • Thinking push builds the image
  • Assuming push deletes images
2. Which of the following is the correct syntax to tag a local Docker image named myapp with the Google Container Registry path gcr.io/my-project/myapp:v1?
easy
A. docker tag myapp gcr.io/my-project/myapp:v1
B. docker push myapp gcr.io/my-project/myapp:v1
C. docker pull myapp gcr.io/my-project/myapp:v1
D. docker build myapp gcr.io/my-project/myapp:v1

Solution

  1. Step 1: Identify the tagging command

    The docker tag command assigns a new name (including registry path) to an existing local image.
  2. Step 2: Confirm correct syntax

    The syntax is docker tag SOURCE_IMAGE TARGET_IMAGE, so docker tag myapp gcr.io/my-project/myapp:v1 is correct.
  3. Final Answer:

    docker tag myapp gcr.io/my-project/myapp:v1 -> Option A
  4. Quick Check:

    Tag syntax = docker tag SOURCE TARGET [OK]
Hint: Tag uses 'docker tag source target' syntax [OK]
Common Mistakes:
  • Using push or pull instead of tag
  • Reversing source and target images
  • Confusing build with tag
3. Given the commands below, what will be the result of running docker images?
docker tag myapp gcr.io/my-project/myapp:v2
docker push gcr.io/my-project/myapp:v2
medium
A. The local image list will only show myapp without the tag
B. The local image list will be empty
C. The local image list will include gcr.io/my-project/myapp:v2
D. The local image list will show myapp:v2 but not the full registry path

Solution

  1. Step 1: Understand tagging effect on local images

    Tagging creates a new name for the same local image, so gcr.io/my-project/myapp:v2 appears locally.
  2. Step 2: Recognize push does not remove local images

    Pushing uploads the image but does not delete local copies, so the tagged image remains listed.
  3. Final Answer:

    The local image list will include gcr.io/my-project/myapp:v2 -> Option C
  4. Quick Check:

    Tag adds local name; push uploads but keeps local image [OK]
Hint: Tag adds local name; push uploads but keeps local image [OK]
Common Mistakes:
  • Thinking push deletes local images
  • Assuming tag does not create new local name
  • Confusing image names without registry path
4. You tried to push an image with the command docker push myapp:v1 but got an error saying the repository was not found. What is the most likely cause?
medium
A. You forgot to tag the image with the full registry path before pushing
B. You need to run docker pull before pushing
C. The image name myapp:v1 is invalid syntax
D. You must delete the local image before pushing

Solution

  1. Step 1: Understand push requires full registry path

    To push to Google Container Registry, the image must be tagged with the full path like gcr.io/project-id/image:tag.
  2. Step 2: Identify missing tag as cause of error

    Using only myapp:v1 lacks registry info, so the push command cannot find the remote repository.
  3. Final Answer:

    You forgot to tag the image with the full registry path before pushing -> Option A
  4. Quick Check:

    Push needs full registry tag [OK]
Hint: Push needs full registry path tag [OK]
Common Mistakes:
  • Trying to pull before push
  • Assuming image name syntax is wrong
  • Deleting local image before push
5. You want to update your app image in Google Container Registry with a new version. Which sequence of commands correctly tags, pushes, and then pulls the updated image for deployment?
hard
A. docker build myapp:v2 && docker pull gcr.io/my-project/myapp:v2 && docker push gcr.io/my-project/myapp:v2
B. docker pull gcr.io/my-project/myapp:v2 && docker tag myapp:v2 && docker push myapp:v2
C. docker push myapp:v2 && docker tag myapp gcr.io/my-project/myapp:v2 && docker pull myapp:v2
D. docker tag myapp gcr.io/my-project/myapp:v2 && docker push gcr.io/my-project/myapp:v2 && docker pull gcr.io/my-project/myapp:v2

Solution

  1. Step 1: Tag the local image with the full registry path

    Use docker tag myapp gcr.io/my-project/myapp:v2 to prepare the image for pushing.
  2. Step 2: Push the tagged image to Google Container Registry

    Run docker push gcr.io/my-project/myapp:v2 to upload the image.
  3. Step 3: Pull the updated image to confirm availability for deployment

    Use docker pull gcr.io/my-project/myapp:v2 to download the image where needed.
  4. Final Answer:

    docker tag myapp gcr.io/my-project/myapp:v2 && docker push gcr.io/my-project/myapp:v2 && docker pull gcr.io/my-project/myapp:v2 -> Option D
  5. Quick Check:

    Tag, push, then pull sequence [OK]
Hint: Tag with full path, push, then pull updated image [OK]
Common Mistakes:
  • Pushing before tagging with full path
  • Pulling before pushing updated image
  • Incorrect command order
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard