Docker MCQs – Advanced Docker Concepts

11.) Which networking option allows containers on separate hosts to communicate in a Swarm?

A) Bridge Network
B) Host Network
C) Overlay Network
D) None of the above

Answer: Option C

Explanation: Overlay networks allow containers across different hosts in a Docker Swarm to communicate.

12.) What is the purpose of the docker save command?

A) To save a container’s state
B) To export an image as a tar file
C) To save logs of a container
D) To store an image in Docker Hub

Answer: Option B

Explanation: The docker save command is used to export an image as a tar file, which can be shared or transferred.

13.) What does the –detach or -d flag do when starting a container?

A) Stops the container immediately
B) Runs the container in detached (background) mode
C) Enables container debugging
D) Allocates interactive shell access

Answer: Option B

Explanation: The –detach or -d flag runs the container in the background (detached mode).

14.) Which storage option allows Docker volumes to persist across host machines?

A) Bind Mounts
B) tmpfs
C) NFS or External Storage Drivers
D) Overlay Network

Answer: Option C

Explanation: External storage drivers, like NFS, allow Docker volumes to persist across host machines.

15.) What is the function of Docker Healthchecks?

A) To monitor CPU and memory usage
B) To validate container readiness and health
C) To check Docker daemon status
D) To enforce network security policies

Answer: Option B

Explanation: Docker Healthchecks validate the readiness and health of containers, ensuring smooth operations.

16.) What is the role of namespaces in Docker?

A) To isolate resources within containers
B) To enable Swarm orchestration
C) To manage container healthchecks
D) To optimize image layers

Answer: Option A

Explanation: Namespaces in Docker provide resource isolation for containers, such as process and network isolation.

17.) What does the –no-cache flag do during docker build?

A) Skips Dockerfile validation
B) Disables multi-stage builds
C) Cleans up image cache after building
D) Builds without using cached layers

Answer: Option D

Explanation: The –no-cache flag builds an image without using cached layers, ensuring a fresh build.

18.) How do you enable Docker Swarm mode?

A) docker swarm create
B) docker swarm init
C) docker cluster enable
D) docker mode activate

Answer: Option B

Explanation: The docker swarm init command initializes Docker Swarm mode on a host.

19.) What does the docker stack ps command display?

A) Logs of a stack’s services
B) Running containers in a stack
C) Status of tasks in a stack
D) Health status of the stack

Answer: Option C

Explanation: The docker stack ps command shows the status of tasks in a stack.

20.) What is the function of cgroups in Docker?

A) Isolates containers on a network
B) Enforces resource limits for containers
C) Validates image signatures
D) Manages Swarm secrets

Answer: Option B

Explanation: Control Groups (cgroups) enforce resource limits like CPU, memory, and I/O for Docker containers.

Leave a Reply

Your email address will not be published. Required fields are marked *