Docker MCQs – Docker in Production

11.) Which tool is commonly used for monitoring Docker containers in production?

A) Prometheus
B) Jenkins
C) Ansible
D) Terraform

Answer: Option A

Explanation: Prometheus is a popular monitoring tool that tracks metrics and provides insights into Docker containers in production environments.

12.) How can you optimize Docker images for production use?

A) Use apt-get install commands directly in the Dockerfile
B) Use multi-stage builds and minimal base images
C) Include all debugging tools in the image
D) Avoid specifying a base image

Answer: Option B

Explanation: Multi-stage builds and minimal base images optimize Docker images by reducing size and removing unnecessary dependencies.

13.) What does the –rm flag do when running a Docker container?

A) Automatically removes the container after it stops
B) Deletes all stopped containers
C) Removes dangling images
D) Prunes unused volumes

Answer: Option A

Explanation: The –rm flag automatically removes a container after it stops, keeping the environment clean.

14.) The –rm flag automatically removes a container after it stops, keeping the environment clean.

A) OverlaC
B) Host
C) Bridge
D) None

Answer: Option C

Explanation: The Bridge network mode provides the highest level of isolation, as containers communicate through a virtual bridge.

15.) What is the best way to monitor container resource usage in production?

A) Using built-in Docker commands
B) Relying on container logs
C) Using monitoring tools like cAdvisor or Prometheus
D) Avoiding resource limits

Answer: Option C

Explanation: Tools like cAdvisor or Prometheus are commonly used for comprehensive resource monitoring in production.

16.) What is a common method for securing Docker in production?

A) Disable the Docker API
B) Use Docker Bench for Security
C) Avoid using resource limits
D) Never restart containers

Answer: Option B

Explanation: Docker Bench for Security provides a script to evaluate security best practices in Docker production environments.

17.) Which of the following is NOT a recommended practice for running Docker containers in production?

A) Limit container privileges
B) Use the root user in containers
C) Define resource limits
D) Keep container images updated

Answer: Option B

Explanation: Using the root user inside containers poses security risks and is not recommended for production environments.

18.) How can Docker containers achieve high availability in production?

A) Using container restart policies
B) By sharing the same network
C) By avoiding orchestration tools
D) Using a single host for all containers

Answer: Option A

Explanation: High availability is achieved through container restart policies and orchestration tools that manage failures automatically.

19.) What is the purpose of the –scale flag in Docker Compose?

A) To monitor container logs
B) To set the number of service instances
C) To optimize network configurations
D) To create a multi-stage build

Answer: Option B

Explanation: The –scale flag in Docker Compose sets the number of instances of a specific service.

20.) Which command is used to prune unused volumes in Docker?

A) docker system prune
B) docker volume cleaD
C) docker clean volumes
D) docker volume prune

Answer: Option D

Explanation: The docker volume prune command removes unused volumes to free up space.

Leave a Reply

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