Docker MCQs with answers Page - 6

Here, you will find a collection of MCQ questions on Docker. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833K Points
Coach

Q. Which command stops and removes all containers defined in a Docker Compose file?

  • (A) docker-compose delete
  • (B) docker-compose shutdown
  • (C) docker-compose stop
  • (D) docker-compose down

A

Admin • 833K Points
Coach

Q. How do you define environment variables in a Docker Compose file?

  • (A) Using an 'env' section
  • (B) Using a 'variables' section
  • (C) Using an '.env' file or 'environment' key
  • (D) Using a 'settings' section

A

Admin • 833K Points
Coach

Q. Which command is used to check logs of a service in Docker Compose?

  • (A) docker-compose logs
  • (B) docker-compose show
  • (C) docker-compose history
  • (D) docker-compose events

A

Admin • 833K Points
Coach

Q. How do you scale a service in Docker Compose?

  • (A) docker-compose extend
  • (B) docker-compose up --scale
  • (C) docker-compose grow
  • (D) docker-compose increase

A

Admin • 833K Points
Coach

Q. What is the purpose of 'depends_on' in a Docker Compose file?

  • (A) To specify service dependencies
  • (B) To set up networking
  • (C) To link to external services
  • (D) To create a shared volume

A

Admin • 833K Points
Coach

Q. Which flag is used with 'docker-compose up' to rebuild images?

  • (A) --build
  • (B) --rebuild
  • (C) --refresh
  • (D) --update

A

Admin • 833K Points
Coach

Q. How do you restart services in Docker Compose?

  • (A) docker-compose restart
  • (B) docker-compose refresh
  • (C) docker-compose reload
  • (D) docker-compose up --restart

A

Admin • 833K Points
Coach

Q. Which command is used to remove unused Docker Compose volumes?

  • (A) docker-compose rm volumes
  • (B) docker-compose clean
  • (C) docker volume prune
  • (D) docker-compose prune

A

Admin • 833K Points
Coach

Q. What is the purpose of the 'build' section in a Docker Compose file?

  • (A) To define how a service is built
  • (B) To specify service dependencies
  • (C) To set up networking
  • (D) To configure environment variables

A

Admin • 833K Points
Coach

Q. Which of the following is a valid restart policy in Docker Compose?

  • (A) always
  • (B) on-failure
  • (C) unless-stopped
  • (D) All of the above

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ