0
0
Dockerdevops~5 mins

Using .dockerignore - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of a .dockerignore file?
A .dockerignore file tells Docker which files and folders to ignore when building an image. This helps make builds faster and smaller by excluding unnecessary files.
Click to reveal answer
beginner
How do you write a pattern in .dockerignore to ignore all .log files?
You write *.log in the .dockerignore file to ignore all files ending with .log.
Click to reveal answer
beginner
True or False: Files listed in .dockerignore are still available on your local machine after the Docker build.
True. The .dockerignore file only affects what files are sent to the Docker build context. It does not delete or change files on your local machine.
Click to reveal answer
beginner
What happens if you do not use a .dockerignore file in your Docker project?
Docker will send all files in the build folder to the Docker daemon. This can make builds slower and images larger because unnecessary files are included.
Click to reveal answer
beginner
How can you ignore a folder named temp using .dockerignore?
Add temp/ to the .dockerignore file to ignore the entire temp folder and its contents.
Click to reveal answer
What does the .dockerignore file control?
AWhich files are sent to the Docker build context
BWhich files are deleted after build
CWhich files are copied into the container at runtime
DWhich files are executed inside the container
Which pattern in .dockerignore ignores all files in the logs folder?
Alogs
B*.logs
Clogs/
D/logs
If you want to ignore all files named secret.txt anywhere in the project, what pattern should you use?
A*/secret.txt
Bsecret.txt
C**/secret.txt
Dsecret.txt/
What is the effect of ignoring files with .dockerignore on the final Docker image size?
AIt reduces the image size by excluding unnecessary files
BIt increases the image size
CIt has no effect on image size
DIt deletes files from the image after build
Which of these files is commonly included in .dockerignore to speed up builds?
Aapp.py
BDockerfile
CREADME.md
Dnode_modules
Explain what a .dockerignore file does and why it is useful in Docker projects.
Think about how sending fewer files to Docker helps.
You got /4 concepts.
    Describe how you would write patterns in .dockerignore to ignore a folder and all files with a certain extension.
    Consider ignoring a folder named 'temp' and all '.log' files.
    You got /3 concepts.