Pushing Images to Artifact Registry
Introduction and Goal
Welcome to the third lesson in our course on working with container registries. In the previous lesson, you created a secure Artifact Registry repository with vulnerability scanning enabled. Now you have an empty repository waiting for container images, but how do you actually get your applications into Artifact Registry?
This lesson bridges that gap by teaching you the complete workflow for getting locally built Docker images into your Artifact Registry repository. We'll start with a simple containerized web application, build it into a Docker image on your local machine, authenticate Docker to work with Artifact Registry, tag the image with the proper Google Cloud naming convention, and finally push it to your repository.
By the end of this lesson, you'll execute the full sequence: docker build to create your image locally, gcloud auth configure-docker to authenticate, docker tag to prepare the image for Artifact Registry, and docker push to upload it. This workflow forms the foundation for all Artifact Registry operations, whether you're working manually or setting up automated CI/CD pipelines.
The sample application we'll use is a minimal Flask-based web application that responds with "Hello from Artifact Registry!" when accessed. While simple, this demonstrates the complete process we'll use for any containerized application, from microservices to complex web applications.
Prerequisites and Repo Check
Before pushing your first image to Artifact Registry, you need to confirm that your repository from the previous lesson exists and gather the specific details required for the push process. The repository URI you created earlier contains your Google Cloud project ID and location, both of which are essential for the tagging and authentication steps.
Run this command to verify your repository exists and note its details:
The output should show your repository details, including the repository format (DOCKER) and location. From this information, you can construct your repository URI, which looks like us-central1-docker.pkg.dev/PROJECT_ID/my-web-app. This URI contains three critical pieces of information: your location (us-central1), your Google Cloud project ID (PROJECT_ID), and your repository name (my-web-app). We'll need these components for the authentication and tagging steps.
Your gcloud CLI must be configured with credentials that have Artifact Registry permissions. The key IAM roles you need are roles/artifactregistry.writer for pushing images and roles/artifactregistry.reader for pulling images. Note that while you needed roles/artifactregistry.repoAdmin to create your repository in the previous lesson, pushing images only requires roles/artifactregistry.writer. This separation allows teams to grant developers push access without giving them repository management permissions. You can verify your current project with:
In the CodeSignal environment, Docker, the gcloud CLI, and all necessary permissions are pre-configured for you. However, understanding these requirements is important when you work on your own development machine or set up CI/CD pipelines in production environments.
