0
0
Dockerdevops~15 mins

Image naming conventions (registry/image:tag) in Docker - Mini Project: Build & Apply

Choose your learning style9 modes available
Image naming conventions (registry/image:tag)
📖 Scenario: You are working with Docker images and need to understand how to name them properly. Docker images use a naming format that helps you identify where the image is stored, what the image is, and which version it is.
🎯 Goal: Learn how to create and use Docker image names with the correct format: registry/image:tag. You will build a simple example of naming an image with a registry, image name, and tag.
📋 What You'll Learn
Create a variable with a Docker image name using the format registry/image:tag
Add a variable for the default registry
Extract the image name and tag from the full image name
Print the extracted image name and tag
💡 Why This Matters
🌍 Real World
Docker images are used to package applications and their environments. Knowing how to name and tag images helps you manage versions and sources clearly.
💼 Career
Understanding image naming conventions is essential for DevOps roles that involve container management, deployment pipelines, and working with container registries.
Progress0 / 4 steps
1
Create a Docker image name variable
Create a variable called full_image_name and set it to the string docker.io/library/ubuntu:22.04.
Docker
Need a hint?

Remember to use quotes around the string value.

2
Add a default registry variable
Create a variable called default_registry and set it to the string docker.io.
Docker
Need a hint?

This variable will help identify the registry part of the image name.

3
Extract image name and tag from full image name
Use the split method on full_image_name to create two variables: image_name for the part after the registry and before the colon, and tag for the part after the colon. For example, image_name should be library/ubuntu and tag should be 22.04.
Docker
Need a hint?

First split by '/' to remove the registry, then split by ':' to separate the tag.

4
Print the extracted image name and tag
Write two print statements to display the values of image_name and tag.
Docker
Need a hint?

Use print(image_name) and print(tag) to show the results.