0
0
Dockerdevops~20 mins

Build context concept in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Build Context Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Docker Build Context
What does the Docker build context include when you run docker build . in a directory?
AAll files and folders in the current directory and its subdirectories are sent to the Docker daemon as the build context.
BOnly the Dockerfile is sent to the Docker daemon as the build context.
COnly files explicitly listed in the Dockerfile are sent as the build context.
DOnly files tracked by Git in the current directory are sent as the build context.
Attempts:
2 left
💡 Hint
Think about what files the Docker daemon needs access to during build.
💻 Command Output
intermediate
2:00remaining
Effect of Large Build Context on Docker Build
You run docker build . in a directory containing a 1GB video file not referenced in the Dockerfile. What is the most likely effect on the build process?
AThe build will be slow because the entire 1GB file is sent as part of the build context to the Docker daemon.
BThe build will be fast because Docker ignores files not referenced in the Dockerfile.
CThe build will fail with an error about large files in the context.
DThe build will only send the Dockerfile and ignore other files.
Attempts:
2 left
💡 Hint
Consider what files Docker sends to the daemon regardless of Dockerfile references.
Configuration
advanced
2:00remaining
Optimizing Docker Build Context with .dockerignore
Which .dockerignore file content will exclude all .log files and the temp directory from the build context?
A
temp
*.log/
B
*.log
temp
C
temp/*
*.log
D
*.log
temp/
Attempts:
2 left
💡 Hint
Remember that directories should end with a slash to exclude them properly.
Troubleshoot
advanced
2:00remaining
Why is my Docker build context unexpectedly large?
You notice your Docker build is very slow. You suspect the build context is too large. Which of the following is the most likely cause?
AYou are using an outdated Docker version that slows down builds.
BYour Dockerfile has syntax errors causing slow builds.
CYou forgot to add a <code>.dockerignore</code> file to exclude unnecessary files and folders.
DYou are running <code>docker build</code> without specifying the Dockerfile.
Attempts:
2 left
💡 Hint
Think about what controls which files are sent to the Docker daemon.
🔀 Workflow
expert
3:00remaining
Correct Order of Steps to Optimize Docker Build Context
Arrange the steps in the correct order to optimize your Docker build context for faster builds.
A1,2,3,4
B3,1,2,4
C1,3,2,4
D3,2,1,4
Attempts:
2 left
💡 Hint
Think about preparing the Dockerfile before excluding files and building.