Challenge - 5 Problems
Compose Build Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of docker-compose build with context path
Given this docker-compose.yml snippet, what will be the output when running
docker-compose build?Docker
services:
web:
build:
context: ./app
dockerfile: Dockerfile.web
image: mywebapp:latestAttempts:
2 left
💡 Hint
The build context and dockerfile path determine where Docker looks for files.
✗ Incorrect
The build context './app' tells Docker to use that directory. The dockerfile 'Dockerfile.web' is found there, so the image builds successfully and is tagged as 'mywebapp:latest'.
❓ Configuration
intermediate2:00remaining
Correct syntax for build args in Compose
Which docker-compose.yml snippet correctly passes build arguments to the Docker build process?
Attempts:
2 left
💡 Hint
Check the official Compose syntax for build arguments.
✗ Incorrect
The correct key is 'args' under 'build'. It accepts a map of argument names and values. Other keys like 'build_args' or 'build-args' are invalid.
❓ Troubleshoot
advanced2:00remaining
Diagnosing build failure due to missing Dockerfile
You run
What is the most likely cause?
docker-compose build but get the error: "Cannot locate specified Dockerfile: Dockerfile.prod". Your docker-compose.yml contains:services:
api:
build:
context: ./backend
dockerfile: Dockerfile.prodWhat is the most likely cause?
Attempts:
2 left
💡 Hint
Check the location of the Dockerfile relative to the context.
✗ Incorrect
The dockerfile path is relative to the build context. If Dockerfile.prod is missing inside ./backend, the build fails with this error.
🔀 Workflow
advanced2:00remaining
Order of steps in multi-stage build with Compose
In a multi-stage Docker build defined in a Dockerfile, which step happens first when running
docker-compose build?Attempts:
2 left
💡 Hint
Think about how Docker processes multi-stage builds.
✗ Incorrect
Docker builds each stage in order because later stages can depend on earlier ones. The final image uses the last stage, but all stages are built sequentially.
✅ Best Practice
expert2:00remaining
Optimizing build cache usage in Compose builds
Which practice best helps Docker Compose reuse build cache effectively when building images?
Attempts:
2 left
💡 Hint
Think about what invalidates Docker cache during build.
✗ Incorrect
Docker cache is invalidated if files in the build context change. Keeping context small and stable helps reuse cache. Using latest tags or random args forces rebuilds. COPY with wildcards can cause unnecessary cache misses.