Dockerfile MCQs with answers Page - 5

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 copies files from the host system to the container?

  • (A) MOVE
  • (B) GET
  • (C) COPY
  • (D) PASTE

A

Admin • 802.91K Points
Coach

Q. What is the function of the `CMD` instruction?

  • (A) Defines the image entry point
  • (B) Runs during the build process
  • (C) Provides default arguments for the container
  • (D) Builds the image

A

Admin • 802.91K Points
Coach

Q. Which instruction sets the working directory inside a Docker container?

  • (A) WORKINGDIR
  • (B) DIR
  • (C) WORKDIR
  • (D) SETDIR

A

Admin • 802.91K Points
Coach

Q. What does the `EXPOSE` instruction do in a Dockerfile?

  • (A) Opens a file
  • (B) Publishes a container to a repository
  • (C) Informs Docker that the container listens on a port
  • (D) Starts a process

A

Admin • 802.91K Points
Coach

Q. How can you specify environment variables in a Dockerfile?

  • (A) SETENV
  • (B) ENV
  • (C) VARIABLE
  • (D) DEFINE

A

Admin • 802.91K Points
Coach

Q. Which Dockerfile instruction is used to add metadata to an image?

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

A

Admin • 802.91K Points
Coach

Q. Which instruction is used to run scripts after a container starts?

  • (A) RUN
  • (B) CMD
  • (C) SCRIPT
  • (D) AFTER

A

Admin • 802.91K Points
Coach

Q. How can you copy files with permissions preserved?

  • (A) COPY --chmod
  • (B) ADD
  • (C) RUN copy
  • (D) EXPORT

A

Admin • 802.91K Points
Coach

Q. Which instruction allows downloading and extracting tar files automatically?

  • (A) COPY
  • (B) GET
  • (C) ADD
  • (D) RUN

A

Admin • 802.91K Points
Coach

Q. What happens if multiple `CMD` instructions are in a Dockerfile?

  • (A) All are executed
  • (B) Only the first is used
  • (C) Only the last is used
  • (D) They are ignored
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