Bird
Raised Fist0
Dockerdevops~20 mins

Image tags and versioning in Docker - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Docker Image Tagging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Understanding Docker image tag output
What is the output of the command docker images --format "{{.Repository}}:{{.Tag}}" | grep '^myapp:' if the local images are:
  • myapp:latest
  • myapp:1.0
  • myapp:1.1
  • otherapp:2.0
Docker
docker images --format "{{.Repository}}:{{.Tag}}" | grep '^myapp:'
ANo output
B
myapp:latest
myapp:1.0
myapp:1.1
otherapp:2.0
Cotherapp:2.0
D
myapp:latest
myapp:1.0
myapp:1.1
Attempts:
2 left
💡 Hint
The grep command filters lines starting with 'myapp:'
🧠 Conceptual
intermediate
1:30remaining
Docker image tag best practice
Which of the following is the best reason to avoid using the latest tag in production deployments?
AThe latest tag is slower to download than versioned tags
BThe latest tag always points to the newest image, which can cause unexpected updates breaking the app
CThe latest tag cannot be pushed to Docker Hub
DThe latest tag uses more disk space on the host
Attempts:
2 left
💡 Hint
Think about stability and predictability in production
🔀 Workflow
advanced
2:00remaining
Tagging and pushing multiple image versions
You built a Docker image locally with ID abc123. You want to tag it as myapp:1.0 and myapp:stable and push both tags to Docker Hub. Which sequence of commands correctly does this?
A
docker tag myapp:1.0 abc123
docker push myapp:1.0
 docker push myapp:stable
B
docker push abc123 myapp:1.0
 docker push abc123 myapp:stable
C
docker tag abc123 myapp:1.0
docker tag abc123 myapp:stable
docker push myapp:1.0
docker push myapp:stable
D
docker build -t myapp:1.0 .
docker push myapp:stable
Attempts:
2 left
💡 Hint
Remember to tag the image ID before pushing tags
❓ Troubleshoot
advanced
1:30remaining
Troubleshooting image pull failure with tags
You run docker pull myapp:2.0 but get the error manifest for myapp:2.0 not found. What is the most likely cause?
AThe tag '2.0' does not exist in the remote repository
BThe image name 'myapp' is invalid
CYou have no internet connection
DDocker daemon is not running
Attempts:
2 left
💡 Hint
Check if the tag exists remotely
✅ Best Practice
expert
2:00remaining
Versioning strategy for Docker images in CI/CD
In a CI/CD pipeline, which tagging strategy best supports traceability and rollback of Docker images?
ATag images with the Git commit SHA and push with that tag
BAlways tag images as 'latest' to simplify deployment
CUse timestamps as tags without linking to source code
DTag images only with semantic version numbers like 1.0, 1.1
Attempts:
2 left
💡 Hint
Think about linking image versions to exact code changes

Practice

(1/5)
1. What is the default tag used by Docker if no tag is specified when pulling an image?
easy
A. stable
B. 1.0
C. latest
D. default

Solution

  1. Step 1: Understand Docker image tagging

    Docker images can have tags to specify versions or variants.
  2. Step 2: Identify the default tag behavior

    If no tag is specified, Docker uses the tag named "latest" by default.
  3. Final Answer:

    latest -> Option C
  4. Quick Check:

    Default tag = latest [OK]
Hint: No tag means Docker uses 'latest' automatically [OK]
Common Mistakes:
  • Assuming 'stable' is default tag
  • Thinking '1.0' is default version
  • Believing 'default' is a valid tag
2. Which of the following is the correct syntax to pull a Docker image with a specific tag?
easy
A. docker pull ubuntu:20.04
B. docker pull ubuntu-20.04
C. docker pull ubuntu/20.04
D. docker pull ubuntu#20.04

Solution

  1. Step 1: Recall Docker image tag syntax

    The correct syntax to specify a tag is image_name:tag.
  2. Step 2: Match syntax with options

    Only docker pull ubuntu:20.04 uses a colon to separate image name and tag correctly.
  3. Final Answer:

    docker pull ubuntu:20.04 -> Option A
  4. Quick Check:

    Use colon ':' to specify tag [OK]
Hint: Use ':' between image name and tag [OK]
Common Mistakes:
  • Using dash '-' instead of colon ':'
  • Using slash '/' instead of colon
  • Using hash '#' instead of colon
3. Given the command docker pull nginx:1.21, what will be the result?
medium
A. Docker throws an error due to invalid tag
B. Docker pulls the latest nginx image ignoring 1.21
C. Docker pulls all nginx images
D. Docker pulls the nginx image tagged 1.21

Solution

  1. Step 1: Analyze the pull command with tag

    The command specifies the image name 'nginx' and tag '1.21'.
  2. Step 2: Understand Docker pull behavior

    Docker pulls the exact image version matching the tag '1.21'.
  3. Final Answer:

    Docker pulls the nginx image tagged 1.21 -> Option D
  4. Quick Check:

    Tag specifies exact image version [OK]
Hint: Tag pulls specific image version, not latest [OK]
Common Mistakes:
  • Assuming tag is ignored and latest is pulled
  • Expecting error for valid tag
  • Thinking all images are pulled
4. You run docker pull alpine and get an error that the image is not found. What is the most likely cause?
medium
A. You forgot to specify the tag, and 'latest' tag is missing
B. The image 'alpine' does not exist on Docker Hub
C. Docker requires a tag to pull any image
D. Your internet connection is down

Solution

  1. Step 1: Understand default tag behavior

    When no tag is specified, Docker tries to pull the 'latest' tag.
  2. Step 2: Identify cause of error

    If the 'latest' tag does not exist for 'alpine', Docker cannot find the image.
  3. Final Answer:

    You forgot to specify the tag, and 'latest' tag is missing -> Option A
  4. Quick Check:

    Missing 'latest' tag causes pull failure [OK]
Hint: Always specify tag if 'latest' is missing [OK]
Common Mistakes:
  • Assuming image does not exist at all
  • Thinking tag is always required
  • Blaming internet without checking tags
5. You want to deploy a Docker image but ensure you always use version 2.5.3, never the latest. Which command correctly pulls this specific version and avoids accidental updates?
hard
A. docker pull myapp:stable
B. docker pull myapp:2.5.3
C. docker pull myapp:latest
D. docker pull myapp

Solution

  1. Step 1: Understand version control with tags

    Using a specific tag like '2.5.3' ensures you get that exact version.
  2. Step 2: Compare options for safety

    docker pull myapp:2.5.3 pulls the exact version. Options B and C pull 'latest' which can change. docker pull myapp:stable depends on tag existence.
  3. Final Answer:

    docker pull myapp:2.5.3 -> Option B
  4. Quick Check:

    Explicit version tag prevents accidental updates [OK]
Hint: Always specify exact version tag to avoid surprises [OK]
Common Mistakes:
  • Using 'latest' tag and getting unexpected updates
  • Assuming 'stable' tag always exists
  • Not specifying any tag and risking version changes
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