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?✗ Incorrect
The
.dockerignore file controls which files and folders are excluded from the build context sent to Docker during image build.Which pattern in
.dockerignore ignores all files in the logs folder?✗ Incorrect
Adding
logs/ ignores the entire logs folder and its contents.If you want to ignore all files named
secret.txt anywhere in the project, what pattern should you use?✗ Incorrect
Simply writing
secret.txt ignores all files with that exact name anywhere in the build context.What is the effect of ignoring files with
.dockerignore on the final Docker image size?✗ Incorrect
Ignoring files reduces the build context size, so fewer files are copied into the image, making it smaller.
Which of these files is commonly included in
.dockerignore to speed up builds?✗ Incorrect
Folders like
node_modules are often large and not needed in the build context, so they are ignored.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.