Dockerfile MCQs with answers Page - 3

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 does the `RUN` instruction do in a Dockerfile?

  • (A) Defines a default command
  • (B) Executes a command at container runtime
  • (C) Executes a command at image build time
  • (D) Deletes a file

A

Admin • 802.91K Points
Coach

Q. Which instruction is used to specify the default command when a container starts?

  • (A) RUN
  • (B) CMD
  • (C) ENTRYPOINT
  • (D) START

A

Admin • 802.91K Points
Coach

Q. How can you add metadata to an image using Dockerfile?

  • (A) META
  • (B) LABEL
  • (C) ANNOTATE
  • (D) INFO

A

Admin • 802.91K Points
Coach

Q. What is the difference between `CMD` and `ENTRYPOINT`?

  • (A) CMD is required; ENTRYPOINT is optional
  • (B) ENTRYPOINT allows arguments; CMD does not
  • (C) CMD provides defaults; ENTRYPOINT defines fixed commands
  • (D) They are interchangeable

A

Admin • 802.91K Points
Coach

Q. What is the purpose of the `COPY` instruction?

  • (A) To copy from image to host
  • (B) To copy from container to host
  • (C) To copy files from host to image
  • (D) To copy files from one image to another

A

Admin • 802.91K Points
Coach

Q. What does `EXPOSE 80` do in a Dockerfile?

  • (A) Starts a service on port 80
  • (B) Makes port 80 available for linking containers
  • (C) Opens a host port
  • (D) Assigns 80 as container ID

A

Admin • 802.91K Points
Coach

Q. What does `ENV APP_ENV=production` do?

  • (A) Creates a label
  • (B) Runs a command
  • (C) Sets an environment variable
  • (D) Creates a user

A

Admin • 802.91K Points
Coach

Q. Which instruction allows combining multiple commands into one layer?

  • (A) MULTI
  • (B) SHELL
  • (C) RUN with &&
  • (D) STACK

A

Admin • 802.91K Points
Coach

Q. What is the result of using multiple `FROM` instructions?

  • (A) Error in build
  • (B) Multiple base images
  • (C) Multi-stage build
  • (D) Multiple containers

A

Admin • 802.91K Points
Coach

Q. What does `VOLUME` do in Dockerfile?

  • (A) Removes files from image
  • (B) Creates persistent storage
  • (C) Increases image size
  • (D) Disables logging
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