
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create a Docker repository
/ 50
Add the image to the repository
/ 50
Artifact Registry is a secure, scalable, and fully managed service for storing, managing, and securing your build artifacts and dependencies. You'll learn how to create a private Docker repository, configure authentication, and push and pull a sample Docker image. This hands-on experience will give you a foundational understanding of how to use Artifact Registry for your containerized applications.
In this lab, you will learn how to perform the following tasks:
Some experience with Docker is recommended for this lab. Feel free to check out the Docker documentation for a refresher or introduction. You can also check out our Introduction to Docker lab for more hands-on practice!
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.
This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details panel.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details panel.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
In this section, you'll create a private Docker repository within Artifact Registry. This repository will serve as a central location to store and manage your Docker images. You'll use the gcloud
command-line tool to create the repository and then verify its creation through the Google Cloud Console.
Open a new Cloud Shell window by clicking the icon () in the top right corner of the console.
Run the following command to get your Project ID and save it as an environment variable:
example-docker-repo
in the location From the search bar at the top of the console, type Artifact Registry and select the first result.
On the Artifact Registry product page, verify you can see your repository. It should resemble the following:
Click Check my progress to verify the objective.
To push and pull images from your newly created Docker repository, you need to configure Docker to authenticate with Artifact Registry. This involves setting up credentials that allow your Docker client to interact with the repository securely.
Before you can push or pull images, you will need to configure Docker to use the Google Cloud CLI to authenticate requests to Artifact Registry.
The command updates your Docker configuration. You can now connect with Artifact Registry in your Google Cloud project to push and pull images.
For information about other authentication methods, see Authentication methods.
You'll need a Docker image to work with in this lab. Instead of building an image from scratch, you'll pull a pre-built sample image from a public repository. This will allow you to focus on interacting with Artifact Registry.
For this lab, you will push a sample image named hello-app
.
Image paths in Artifact Registry include multiple parts. For this sample image:
us-docker.pkg.dev
is the hostname for container images stored in Artifact Registry Docker repositories, which includes the location of the repository (us
).google-samples
is the project ID.containers
is the repository ID./gke/hello-app
is the path to the image in the repository containers
.Now you'll add the sample image to your private repository. This involves tagging the image with the repository name to specify its destination and then pushing it to Artifact Registry.
Before you push the Docker image to Artifact Registry, you must tag it with the repository name.
Tagging the image ensures it's pushed to the correct location, which for this lab is
.
sample-image:tag1
:Where:
-docker.pkg.dev
is the hostname for the Docker repository you created.$PROJECT_ID
is your Google Cloud Project ID.example-docker-repo
is the ID of the repository you created.sample-image
is the image name you want to use in the repository. The image name can be different than the local image name. For this lab you will store the image directly under the repository ID example-docker-repo
.tag1
is a tag you're adding to the Docker image. If you didn't specify a tag, Docker will apply the default tag latest
.You are now ready to push the image to the repository you created.
After you have configured authentication and tagged the local image, you can push the image to the repository that you created.
To push the Docker image, run the following command:
Click Check my progress to verify the objective.
Finally, you'll pull the image that you just pushed to your private repository. This simulates how you would access and use images stored in Artifact Registry in a real-world scenario.
You should see output similar to the following:
In this lab, you successfully created a private Docker repository in Artifact Registry, configured authentication, pushed a sample image to the repository, and pulled the image back down. You now have a basic understanding of how to use Artifact Registry to manage your Docker images.
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated November 28, 2024
Lab Last Tested November 28, 2024
Copyright 2024 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one