Challenge - 5 Problems
Docker Build Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this Docker build command?
You run the command
docker build -t myapp:latest . in a directory with a valid Dockerfile. What will be the result?Attempts:
2 left
💡 Hint
The '-t' flag is used to name and tag the image during build.
✗ Incorrect
The command 'docker build -t myapp:latest .' builds the Docker image from the current directory and tags it with the name 'myapp' and tag 'latest'. This is the standard way to name images during build.
💻 Command Output
intermediate2:00remaining
What error does this Docker build command produce?
You run
docker build -f Dockerfile.dev . but the file 'Dockerfile.dev' does not exist in the directory. What error will Docker show?Attempts:
2 left
💡 Hint
The '-f' flag specifies a Dockerfile name. If missing, Docker uses 'Dockerfile'.
✗ Incorrect
Docker looks for the file specified by '-f'. If it does not exist, it returns an error saying the Dockerfile was not found.
🔀 Workflow
advanced2:00remaining
Which option correctly builds a Docker image using a specific Dockerfile and no cache?
You want to build an image named 'webapp:1.0' using the Dockerfile named 'Dockerfile.prod' and ensure no cache is used during build. Which command is correct?
Attempts:
2 left
💡 Hint
The order of flags matters; the context path must be last.
✗ Incorrect
The correct syntax places the '-f' and '--no-cache' flags before the context path '.' and specifies the tag with '-t'. Option A follows this syntax exactly.
❓ Troubleshoot
advanced2:00remaining
Why does this Docker build command fail with a syntax error?
You run
docker build -t myimage . -f Dockerfile and get a syntax error. What is the cause?Attempts:
2 left
💡 Hint
Flags must appear before the context path in the command.
✗ Incorrect
Docker expects all flags before the context path. Placing '-f Dockerfile' after '.' causes Docker to treat it as a build context, leading to an error.
✅ Best Practice
expert2:00remaining
What is the best practice to reduce image size when building with Docker?
You want to build a small Docker image for production. Which practice below helps reduce the final image size?
Attempts:
2 left
💡 Hint
Multi-stage builds separate build environment from runtime environment.
✗ Incorrect
Multi-stage builds allow you to compile or build your app in one stage and copy only the needed files to a smaller final image, reducing size and attack surface.