Challenge - 5 Problems
Docker GitHub Actions Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of Docker build in GitHub Actions
You have this GitHub Actions step to build a Docker image:
What will be the output if the Dockerfile is missing in the repository root?
- name: Build Docker Image
run: docker build -t myapp:latest .What will be the output if the Dockerfile is missing in the repository root?
Attempts:
2 left
💡 Hint
Docker build requires a Dockerfile in the specified context directory.
✗ Incorrect
Docker build command looks for a Dockerfile in the current directory by default. If missing, it throws an error indicating it cannot find the Dockerfile.
🔀 Workflow
intermediate2:00remaining
Correct GitHub Actions step to push Docker image
Which GitHub Actions step correctly logs in to Docker Hub and pushes an image named 'myapp:latest'?
Attempts:
2 left
💡 Hint
Docker login must happen before pushing the image.
✗ Incorrect
You must login to Docker Hub before pushing images. The login command requires username and password flags. The order matters: login first, then push.
❓ Configuration
advanced2:00remaining
GitHub Actions Docker cache usage
You want to speed up Docker builds in GitHub Actions by caching layers. Which configuration snippet correctly uses the official Docker cache action?
Attempts:
2 left
💡 Hint
Cache key should depend on Dockerfile content hash for cache invalidation.
✗ Incorrect
Caching Docker layers requires a cache path and a key that changes when Dockerfile changes. Option B uses the correct path and a key based on Dockerfile hash.
❓ Troubleshoot
advanced2:00remaining
Diagnosing Docker build failure in GitHub Actions
A GitHub Actions workflow fails with this error during docker build:
What is the most likely cause?
failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /github/workspace/Dockerfile: no such file or directory
What is the most likely cause?
Attempts:
2 left
💡 Hint
The error says it cannot open the Dockerfile file.
✗ Incorrect
The error indicates the Dockerfile is not found in the expected location. This usually means the file is missing or named differently.
✅ Best Practice
expert3:00remaining
Optimal multi-stage Docker build in GitHub Actions
You want to build a multi-stage Docker image in GitHub Actions to reduce final image size. Which Dockerfile snippet correctly implements a two-stage build for a Go application?
Attempts:
2 left
💡 Hint
The final stage should copy the binary from the builder stage using --from.
✗ Incorrect
Multi-stage builds use named stages. The final stage copies the built binary from the builder stage using COPY --from=builder. Option D correctly implements this.