Dockerfile MCQs with answers Page - 2

You will find multiple-choice questions (MCQs) related to #Dockerfile here. Go through these questions to prepare effectively for your upcoming exams and interviews.

To view the correct answer for any question, simply click the "Show Answer" button.

Have a question to share? Click on "Add Question" to contribute!

A

Admin • 802.91K Points
Coach

Q. What is the effect of using multiple RUN commands in a Dockerfile?

  • (A) Creates multiple layers
  • (B) Overwrites previous instructions
  • (C) Merges commands into one layer
  • (D) Deletes temporary files

A

Admin • 802.91K Points
Coach

Q. Which best practice helps reduce Docker image size?

  • (A) Use multiple COPY instructions
  • (B) Use large base images
  • (C) Combine RUN commands with &&
  • (D) Avoid ENV instructions

A

Admin • 802.91K Points
Coach

Q. What does the VOLUME instruction do?

  • (A) Deletes temporary data
  • (B) Mounts host folder during build
  • (C) Creates a mount point for persistent data
  • (D) Sets working directory

A

Admin • 802.91K Points
Coach

Q. What is a multi-stage build in Dockerfile?

  • (A) Using multiple Dockerfiles
  • (B) Running multiple containers
  • (C) Using multiple base images to reduce final image size
  • (D) Combining Docker Compose files

A

Admin • 802.91K Points
Coach

Q. Which command builds a Docker image from a Dockerfile?

  • (A) docker run
  • (B) docker pull
  • (C) docker build
  • (D) docker start

A

Admin • 802.91K Points
Coach

Q. Where is the default context path when building a Dockerfile?

  • (A) /root
  • (B) The path where the Dockerfile is located
  • (C) /usr/bin
  • (D) /etc/docker

A

Admin • 802.91K Points
Coach

Q. Which instruction is used to switch the user in a Dockerfile?

  • (A) GROUP
  • (B) ENV
  • (C) USER
  • (D) EXEC

A

Admin • 802.91K Points
Coach

Q. Which of the following is not a valid Dockerfile instruction?

  • (A) FROM
  • (B) COPY
  • (C) PUSH
  • (D) RUN

A

Admin • 802.91K Points
Coach

Q. Where is the best place to put a `.dockerignore` file?

  • (A) Inside /etc
  • (B) Outside the Dockerfile directory
  • (C) In the same directory as Dockerfile
  • (D) In /usr/bin

A

Admin • 802.91K Points
Coach

Q. Which instruction in Dockerfile is used to specify the base image?

  • (A) BASE
  • (B) FROM
  • (C) IMAGE
  • (D) START
What's Tag

As you may know, questions are organized under broad categories. Each category can include various types of questions. For example, the "History" category might contain questions about the Revolt of 1857, Shivaji Maharaj, Ancient History, Buddhism, and more.

To further refine this organization, we've introduced tags, which act as sub-categories to group questions more specifically.

Verified users can add tags to any question. If you have any suggestions regarding this system, we'd love to hear from you. Contact Us

Learn More