Docker MCQs – Introduction to Docker

21.) What is the role of Docker CLI?

A) To provide a command-line interface for interacting with Docker
B) To monitor container performance
C) To host containerized applications
D) To optimize Docker image builds

Answer: Option A

Explanation: Docker CLI (Command-Line Interface) allows users to interact with Docker Daemon to manage images, containers, and other resources.

22.) What is the primary purpose of Docker volumes?

A) To manage network configurations
B) To provide persistent storage for containers
C) To monitor container performance
D) To share images between containers

Answer: Option B

Explanation: Docker volumes are used to store data persistently, even after a container is stopped or removed.

23.) What does the -d option in the docker run command do?

A) Runs the container in interactive mode
B) Stops the container after execution
C) Runs the container in detached mode
D) Deletes the container after it stops

Answer: Option C

Explanation: The -d option runs the container in detached mode, allowing it to run in the background.

24.) What is the default base image for most Docker images?

A) CentOS
B) Ubuntu
C) Alpine
D) Debian

Answer: Option C

Explanation: Alpine is commonly used as the default base image because it is lightweight and optimized for containerization.

25.) What is the command to stop all running containers?

A) docker ps -q
B) docker stop $(docker ps -q)
C) docker rm $(docker ps -a)
D) docker pause $(docker ps)

Answer: Option B

Explanation: The command docker stop $(docker ps -q) stops all running containers by fetching their IDs with docker ps -q.

Leave a Reply

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