0
0
Dockerdevops~20 mins

Tagging images during build in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Docker Tagging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of this Docker build command?
You run the command docker build -t myapp:1.0 . in a directory with a valid Dockerfile. What will be the tag of the built image?
Docker
docker build -t myapp:1.0 .
AThe image will be tagged as 'myapp:latest'.
BThe image will be tagged as 'latest'.
CThe image will be tagged as 'myapp:1.0'.
DThe image will have no tag.
Attempts:
2 left
💡 Hint
The -t option sets the tag explicitly.
Configuration
intermediate
1:30remaining
Which Dockerfile instruction sets the image tag during build?
You want to set the image tag inside the Dockerfile itself during build time. Which instruction achieves this?
ALABEL version="1.0"
BThere is no Dockerfile instruction to set the image tag; tags are set during the docker build command.
CENV TAG=1.0
DTAG myapp:1.0
Attempts:
2 left
💡 Hint
Think about where tags are applied in Docker workflow.
🔀 Workflow
advanced
2:00remaining
How to tag the same image with multiple tags during build?
You want to build a Docker image and tag it as both 'myapp:1.0' and 'myapp:latest' in one command. Which command achieves this?
Adocker build -t myapp:1.0,latest .
Bdocker build -tag myapp:1.0 -tag myapp:latest .
Cdocker build --tag myapp:1.0 --tag myapp:latest .
Ddocker build -t myapp:1.0 -t myapp:latest .
Attempts:
2 left
💡 Hint
Multiple -t options can be used.
Troubleshoot
advanced
2:00remaining
Why does this Docker build command fail to tag the image?
You run docker build . -t myapp:1.0 but the image is not tagged as expected. What is the problem?
Docker
docker build . -t myapp:1.0
AThe -t option must come before the build context '.'
BThe tag 'myapp:1.0' is invalid
CDockerfile is missing in the directory
DThe build context '.' is incorrect
Attempts:
2 left
💡 Hint
Check the order of options and arguments in the command.
Best Practice
expert
2:30remaining
What is the best practice for tagging images in CI/CD pipelines?
In a CI/CD pipeline, you want to tag Docker images to track builds uniquely and also have a stable tag for deployment. Which tagging strategy is best?
ATag images with the commit SHA and also tag the same image as 'latest' for deployment
BOnly tag images as 'latest' to keep it simple
CTag images with random numbers to avoid collisions
DTag images with timestamps only
Attempts:
2 left
💡 Hint
Consider traceability and stable references.