Courses
Docker Intermediate: Images and Compose That Survive Real Projects
Check Yourself: Dockerfiles That Don't Rot
Five scenario questions on the build context, .dockerignore patterns, ENTRYPOINT, CMD and stop signals. If you miss more than one, reread the lessons in this section.
Course content
Join this Course
Sign in to save your progress.
-
Dockerfiles That Don't Rot
-
.dockerignore and What Belongs in the Build Context
-
ENTRYPOINT, CMD and When to Override Them
-
-
-
Data That Outlives Containers
-
Bind Mounts vs Named Volumes: Which One When
-
Permissions, Ownership and Why the Container Can't Write
-
-
-
Networks Beyond Defaults
-
Bridge Networks, Aliases and DNS
-
Publish Ports Without Exposing Everything
-
-
-
Compose for Real Apps
-
Services, depends_on and Healthchecks
-
Environment Files, Secrets and What Not to Commit
-
-
-
Images Across Machines
-
Tag Images So You Can Find Them Later
-
Push and Pull From a Registry Without Surprises
-
-
- Final Check: Docker Intermediate
1.
A build says it is transferring 1.4 GB of context for a project whose source code is 3 MB. The Dockerfile only copies the src folder. What is the most likely cause and the right fix?
The Dockerfile has too many RUN lines. Merge them into one.
Docker always sends 1.4 GB the first time and caches it forever.
The build context is the whole project folder, including large folders such as test data or build output. Add them to .dockerignore.
COPY src is slow, so replace it with COPY . . to speed it up.
2.
Your Dockerfile has COPY . . and the project folder holds a .env file with a password. You push the image to a private registry. What is true?
The password is safe, because a private registry encrypts every file in the image.
COPY skips files that start with a dot by default.
Anyone who can pull the image can read the password, and deleting the file in a later step does not remove it from the earlier layer.
The password is only in the image if you also print it with RUN.
3.
A .dockerignore file contains the line *.txt. A file named notes/todo.txt is still copied into the image, while README.txt in the project root is not. Why?
Docker never ignores files inside subfolders.
The ignore file is only read for the first COPY line.
The file in notes is newer, and newer files are always kept.
The pattern *.txt is matched from the context root and a star does not cross folders, so only top-level files match. Start the pattern with a double star and a slash to match at any depth.
4.
An image has ENTRYPOINT ["echo", "greeting:"] and CMD ["world"]. You run docker run IMAGE everyone. What is printed?
5.
A container built from your image takes ten seconds to stop and its shutdown message never appears. The Dockerfile ends with CMD python app.py; echo done. What is the cause?
About
Five scenario questions on the build context, .dockerignore patterns, ENTRYPOINT, CMD and stop signals. If you miss more than one, reread the lessons in this section.
- Duration
- 5 min
- Last update
- 08/01/2026
Was this helpful?
0
0
Comments (0)
Sign in to commentNo comments yet.