Docker MCQs – Docker Compose

21.) What is the purpose of the context key in the docker-compose.yml file?

A) To define environment variables
B) To specify container dependencies
C) To set the working directory of the container
D) To specify the build location for the Dockerfile

Answer: Option D

Explanation: The context key specifies the build location for the Dockerfile.

22.) Which command is used to pause all running containers in Docker Compose?

A) docker-compose stop
B) docker-compose pause
C) docker-compose suspend
D) docker-compose hold

Answer: Option B

Explanation: The docker-compose pause command pauses all running containers managed by Compose.

23.) What is the service key used for in a docker-compose.yml file?

A) To specify individual services in the Compose setup
B) To define container networking
C) To configure environment variables
D) To link containers

Answer: Option A

Explanation: The services key defines the individual services in the Compose setup.

24.) How do you update a running container’s configuration in Docker Compose?

A) Restart the container
B) Rebuild the container and restart using docker-compose up –build
C) Use the docker-compose update command
D) Edit the container configuration manually

Answer: Option B

Explanation: Updating a running container’s configuration requires rebuilding it and restarting using docker-compose up –build.

25.) Which of the following is NOT an advantage of Docker Compose?

A) Simplifies multi-container setup
B) Allows easy scaling of services
C) Provides built-in monitoring and alerting
D) Manages container dependencies automatically

Answer: Option C

Explanation: Docker Compose does not provide built-in monitoring or alerting features; external tools are required for that purpose.

Leave a Reply

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