Skip to content

Docker Level 2, Task 1: Image Management - Pulling and Tagging

For my first task in Docker Level 2, I dove into the essential skill of image management. The goal was to fetch a specific image from the public Docker Hub and then give it a new, more descriptive name for our internal project. This task was a perfect introduction to how teams manage and organize their container blueprints.

I learned the clear distinction between pulling (downloading) an image and tagging (aliasing) it, and the verification step drove home the point that tagging is an efficient, metadata-only operation that doesn't waste disk space.

Table of Contents


The Task

My objective was to perform two actions on App Server 3: 1. Pull the Docker image busybox:musl from the public Docker Hub. 2. Re-tag that same image with a new name: busybox:blog.


My Step-by-Step Solution

The process was straightforward and performed entirely on the command line of App Server 3.

Step 1: Connect to the Server

First, I logged into the correct server.

ssh banner@stapp03

Step 2: Pull the Image

I used the docker pull command to download the specified image from Docker Hub.

sudo docker pull busybox:musl
I could see the output as Docker fetched the image layers and assembled them on the server.

Step 3: Re-tag the Image

Next, I used the docker tag command to create the new alias. The syntax was docker tag <source> <destination>.

sudo docker tag busybox:musl busybox:blog
This command completed instantly, which was my first clue that it wasn't a copy operation.

Step 4: Verification

This was the most important step to confirm my understanding. I listed all the Docker images on the server.

sudo docker images
The output was crystal clear and proved the task was successful.
REPOSITORY          TAG       IMAGE ID       CREATED        SIZE
busybox             blog      a9286defaba4   5 weeks ago    1.4MB
busybox             musl      a9286defaba4   5 weeks ago    1.4MB
The key piece of evidence was that both images had the exact same Image ID (a9286defaba4).


Why Did I Do This? (The "What & Why")

- What is docker pull? This is the command used to download Docker images from a registry. By default, it connects to the public Docker Hub, which is a massive library of official and community-contributed images. busybox is a famous, incredibly lightweight image that contains a basic set of Linux command-line utilities.

  • What is docker tag? This is the command used to create an alias or a new name for an existing image. This is a critical workflow for a few reasons:
    • Project Clarity: Renaming a generic image like busybox:musl to something project-specific like busybox:blog makes its purpose much clearer to the rest of the team.
    • Versioning: It's the standard way to version your own application images (e.g., tagging your build as my-awesome-app:v2.1.5).
    • Pushing to Registries: Before you can push an image to a private or custom registry, you must first tag it with the registry's address (e.g., docker tag my-app:latest my-private-registry.com/my-app:latest).

Deep Dive: The Magic of the Shared Image ID

The most valuable lesson from this task came from the verification step. Seeing that both busybox:musl and busybox:blog shared the same IMAGE ID was the "aha!" moment.

It proves that docker tag does not create a new copy of the image. It doesn't duplicate the data or take up more disk space. It simply adds another pointer or label to the exact same underlying set of files and layers that are identified by that unique hash (a9286defaba4).

This is an incredibly efficient design. It means you can have multiple tags for different environments (e.g., my-app:latest, my-app:production, my-app:staging-approved) all pointing to the same build, without wasting a single byte of storage.


Common Pitfalls

- Forgetting the Source Tag: If I had run docker tag busybox busybox:blog, the command would have defaulted to using the busybox:latest tag as the source, which might not have been the musl version I specifically pulled. - Misunderstanding the Operation: Thinking that docker tag is a copy command. This could lead to confusion about disk space usage. - Typo in the Name: A simple typo in either the source or destination image name would result in an error or an incorrectly named tag.


Exploring the Commands Used

- sudo docker pull busybox:musl: Fetches the busybox image with the musl tag from Docker Hub and saves it to the local server. - sudo docker tag busybox:musl busybox:blog: Creates a new tag named busybox:blog that points to the exact same image ID as busybox:musl. - sudo docker images: Lists all the Docker images stored on the local machine, showing their repository name, tag, unique ID, creation date, and size. This was the key command for verifying my work.