Dockerfile MCQs with answers Page - 1

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. Which Dockerfile instruction is used to specify the base image?

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

A

Admin • 802.91K Points
Coach

Q. What does the RUN instruction do in a Dockerfile?

  • (A) Starts the container
  • (B) Executes a command while building the image
  • (C) Sets default command for container
  • (D) Exposes a port

A

Admin • 802.91K Points
Coach

Q. Which Dockerfile instruction sets the working directory inside the container?

  • (A) CMD
  • (B) WORKDIR
  • (C) VOLUME
  • (D) ENTRYPOINT

A

Admin • 802.91K Points
Coach

Q. Which instruction is used to copy files from the host to the image?

  • (A) RUN
  • (B) COPY
  • (C) CMD
  • (D) EXPOSE

A

Admin • 802.91K Points
Coach

Q. What does the CMD instruction do?

  • (A) Build the image
  • (B) Defines default command to run when container starts
  • (C) Mount a volume
  • (D) Update system packages

A

Admin • 802.91K Points
Coach

Q. Which instruction in Dockerfile is best for setting environment variables?

  • (A) ARG
  • (B) ENV
  • (C) SET
  • (D) CMD

A

Admin • 802.91K Points
Coach

Q. What is the use of the EXPOSE instruction in a Dockerfile?

  • (A) To run a service
  • (B) To open a port on the host
  • (C) To document which port the container listens on
  • (D) To expose a volume

A

Admin • 802.91K Points
Coach

Q. Which instruction is used to include metadata labels in a Dockerfile?

  • (A) LABEL
  • (B) TAG
  • (C) INFO
  • (D) ENV

A

Admin • 802.91K Points
Coach

Q. What is the difference between CMD and ENTRYPOINT?

  • (A) ENTRYPOINT is used during build only
  • (B) CMD cannot be overridden
  • (C) CMD sets default arguments, ENTRYPOINT sets fixed command
  • (D) They are the same

A

Admin • 802.91K Points
Coach

Q. Which instruction allows the Dockerfile to accept variables at build time?

  • (A) ENV
  • (B) ARG
  • (C) CMD
  • (D) COPY
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