Dockerfile MCQs with answers Page - 4

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 instruction is best for downloading dependencies during image build?

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

A

Admin • 802.91K Points
Coach

Q. What’s the difference between `ADD` and `COPY`?

  • (A) `ADD` has more features than `COPY`
  • (B) `COPY` can extract archives
  • (C) `ADD` only copies files
  • (D) `COPY` supports remote URLs

A

Admin • 802.91K Points
Coach

Q. Which Dockerfile instruction defines the user to run subsequent commands?

  • (A) USER
  • (B) RUNAS
  • (C) EXEC
  • (D) LOGIN

A

Admin • 802.91K Points
Coach

Q. How can you reduce image size while writing Dockerfiles?

  • (A) Use larger base images
  • (B) Avoid multi-stage builds
  • (C) Use multi-stage builds
  • (D) Use many RUN instructions

A

Admin • 802.91K Points
Coach

Q. What is the default shell in Dockerfile on Linux containers?

  • (A) cmd
  • (B) /bin/bash
  • (C) /bin/sh -c
  • (D) /usr/shell

A

Admin • 802.91K Points
Coach

Q. Which instruction can be used to copy files with permission changes?

  • (A) COPY --chmod
  • (B) ADD --perm
  • (C) RUN cp
  • (D) USER chmod

A

Admin • 802.91K Points
Coach

Q. Which instruction should be used to clean up cache during image build?

  • (A) CMD clean
  • (B) RUN rm -rf /var/cache && apt-get clean
  • (C) CLEAN
  • (D) RESET

A

Admin • 802.91K Points
Coach

Q. How do you override a CMD at runtime?

  • (A) Using docker override
  • (B) By editing the image
  • (C) By providing a command in `docker run`
  • (D) You cannot override CMD

A

Admin • 802.91K Points
Coach

Q. What happens if both `CMD` and `ENTRYPOINT` are defined?

  • (A) `CMD` is ignored
  • (B) `ENTRYPOINT` runs first
  • (C) `CMD` arguments are passed to `ENTRYPOINT`
  • (D) `CMD` and `ENTRYPOINT` conflict

A

Admin • 802.91K Points
Coach

Q. What is the purpose of the `FROM` instruction in a Dockerfile?

  • (A) To define environment variables
  • (B) To specify the base image
  • (C) To expose ports
  • (D) To start a container
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