Preparing for a Docker certification, interview, or containerization role? This Docker MCQs collection is your practical resource for testing Docker knowledge. It covers Docker fundamentals, images, Dockerfiles, commands, containers, networking, volumes, Compose, Swarm, security, troubleshooting, CI/CD, and production practices.
Note: Score 60% or higher to unlock an exclusive offer of up to 50% off on self-paced Docker courses.
Let’s begin!
1. What is Docker primarily used for?
2. What is a container in Docker?
3. Which component provides the command-line interface for interacting with Docker?
4. What is the Docker daemon responsible for?
5. Which component stores and distributes Docker images?
6. What is Docker Hub?
7. What does containerization help improve?
8. How do Docker containers generally differ from virtual machines?
9. Which Docker object is a read-only template used to create containers?
10. What is a Docker container's writable layer?
11. What is a Docker image?
12. Which command builds an image from a Dockerfile?
13. Which command lists local Docker images?
14. Which command downloads an image from a registry?
15. Which command uploads an image to a registry?
16. What is an image tag commonly used for?
17. What does the image name nginx:latest contain?
18. What is an image digest used for?
19. Why are minimal base images often preferred?
20. What is a private registry used for?
21. What is a Dockerfile?
22. Which Dockerfile instruction specifies the base image?
23. Which instruction copies files from the build context into an image?
24. Which instruction can copy files while supporting additional source features such as remote URLs or archives?
25. Which Dockerfile instruction executes a command while building the image?
26. Which instruction sets the default command for a container?
27. Which instruction sets an executable as the container entrypoint?
28. Which Dockerfile instruction sets the working directory?
29. What does EXPOSE in a Dockerfile do?
30. What is the purpose of .dockerignore?
31. Which command lists running containers?
32. Which command lists running and stopped containers?
33. Which command creates and starts a new container?
34. Which command starts an existing stopped container?
35. Which command stops a running container gracefully?
36. Which command immediately terminates a container?
37. Which command removes a container?
38. Which command removes a Docker image?
39. Which command displays container logs?
40. Which command opens a command inside a running container?
41. Which state indicates that a Docker container is currently executing its main process?
42. What happens when the main process of a normal Docker container exits?
43. Which command creates a container without starting it?
44. Which command restarts a container?
45. What is docker inspect commonly used for?
46. What does docker stats display?
47. What does a restart policy control?
48. Which restart policy restarts a container unless it has been explicitly stopped?
49. Why should a container normally run one primary application process?
50. What is container exit code 0 generally associated with?
51. What is the default Docker network driver commonly used for standalone containers?
52. What is a user-defined bridge network useful for?
53. What does host networking do on a Linux Docker host?
54. What is an overlay network commonly used for?
55. What is port publishing used for?
56. What does -p 8080:80 generally mean in docker run?
57. Why are container names useful for communication on user-defined networks?
58. What is the purpose of an internal Docker network?
59. What does DNS-based service discovery allow containers to do?
60. Which Docker network driver can attach a container directly to a host interface for specialized networking?
61. Why are Docker volumes used?
62. Where are named volumes managed by Docker?
63. Which command creates a named Docker volume?
64. Which command lists Docker volumes?
65. What happens to data in a named volume when its container is removed?
66. What is a bind mount?
67. When are bind mounts commonly useful?
68. What is a tmpfs mount?
69. Why should application data generally not be stored only in the container writable layer?
70. Which command removes unused Docker volumes when explicitly requested with the appropriate prune operation?
71. What is Docker Compose primarily used for?
72. Which file format is commonly used by Docker Compose?
73. What can a Compose file define?
74. Which command starts services defined in a Compose application?
75. Which command stops and removes Compose application containers and networks?
76. What does docker compose build do?
77. What does depends_on express in Compose?
78. How are Compose service-to-service connections commonly made?
79. Why are Compose volumes useful?
80. What is a common use case for Docker Compose?
81. What is Docker Swarm?
82. What is a Swarm manager node responsible for?
83. What is a Swarm worker node?
84. What is a Swarm service?
85. What is a Swarm task?
86. Which command initializes a new Swarm?
87. Which command lists services in a Swarm?
88. Which command changes the number of replicas for a Swarm service?
89. What is a key benefit of orchestration?
90. Does Docker Swarm provide native autoscaling of service replicas based on metrics?
91. What is container isolation?
92. Which Linux feature provides process and resource isolation for containers?
93. Which namespace isolates process IDs?
94. Which namespace isolates network resources?
95. Which namespace isolates filesystem mount points?
96. What are cgroups primarily used for?
97. Why are cgroups useful in multi-container environments?
98. What does a user namespace help isolate?
99. What is a noisy-neighbor problem?
100. Why should namespaces and cgroups be considered together?
101. Why is running a container as a non-root user recommended?
102. What is Docker image scanning used for?
103. Which tool is included in Docker's ecosystem for image security insights?
104. Why are minimal images useful for security?
105. What is an SBOM?
106. Why is image signing useful?
107. What is a Docker secret intended for?
108. Why should secrets not be hardcoded into Dockerfiles?
109. What is the principle of least privilege in container security?
110. Why should the Docker socket be protected?
111. Which command provides live CPU and memory statistics for containers?
112. What does a container memory limit do?
113. Why set CPU limits on containers?
114. What can happen when a container exceeds a strict memory limit?
115. What is resource reservation intended to communicate?
116. Why monitor container resource usage?
117. Which resource is commonly constrained with Docker runtime options?
118. What is CPU throttling?
119. Why can horizontal scaling help with resource pressure?
120. What should be reviewed when a container repeatedly runs out of memory?
121. Which command is a good first step when investigating a container startup failure?
122. What does docker inspect help troubleshoot?
123. Which command can provide an interactive shell inside a running container?
124. If a container works locally but fails in production, what should be checked first?
125. What does a container's restart loop often indicate?
126. Why compare image versions between environments?
127. What can docker ps -a reveal during troubleshooting?
128. Why inspect mounted volumes during a production failure?
129. Why inspect environment variables in a failed deployment?
130. What is a useful response to a slow Docker image build?
131. What is a multi-stage Docker build?
132. Why use multi-stage builds?
133. How can Docker layer caching speed up builds?
134. Why place frequently changing Dockerfile instructions later?
135. What does a .dockerignore file improve?
136. Why avoid copying unnecessary files into an image?
137. Why pin important dependency or base image versions?
138. What is a build context?
139. Why should dependency installation be cached where practical?
140. What is a runtime image?
141. What is Kubernetes primarily designed for?
142. How does Docker differ from Kubernetes?
143. Can Docker and Kubernetes be used together?
144. What is a Kubernetes Pod?
145. What is a Kubernetes Service?
146. Which platform is generally associated with cluster-wide container orchestration and self-healing?
147. What is Docker Swarm compared with Kubernetes?
148. Why might Kubernetes be selected for complex deployments?
149. What does self-healing mean in container orchestration?
150. Why are containers useful to Kubernetes?
You Can Also Check:
1. Docker Interview Questions and Answers
2. Docker Tutorial for Beginners
3. Kubernetes vs Docker: What's the Difference