Quiz Details
QZ-20251028-30315
Topics:
Dockerfile
Difficulty:
Level 3 - Medium
Questions:
10
Generated:
October 28, 2025 at 10:39 AM
Generated by:
Elli Watson
Instructions: Select an answer for each question and click "Check Answer" to see if you're correct. Then view the explanation to learn more!
1 What is the purpose of a Dockerfile?
Correct Answer:
D
Explanation: A Dockerfile contains a series of instructions that specify how to build a Docker image, including the base image, environment variables, and commands to run.
Explanation: A Dockerfile contains a series of instructions that specify how to build a Docker image, including the base image, environment variables, and commands to run.
2 Which command is used to build a Docker image from a Dockerfile?
Correct Answer:
A
Explanation: The 'docker build' command is used to create a Docker image from the instructions specified in a Dockerfile.
Explanation: The 'docker build' command is used to create a Docker image from the instructions specified in a Dockerfile.
3 In a Dockerfile, which instruction is used to copy files from the host to the Docker image?
Correct Answer:
C
Explanation: The 'COPY' instruction is used to copy files and directories from the host file system into the Docker image.
Explanation: The 'COPY' instruction is used to copy files and directories from the host file system into the Docker image.
4 What does the FROM instruction in a Dockerfile do?
Correct Answer:
C
Explanation: The 'FROM' instruction specifies the base image for the new image being built, which serves as the starting point.
Explanation: The 'FROM' instruction specifies the base image for the new image being built, which serves as the starting point.
5 Which instruction would you use to execute a command in a Dockerfile during the build process?
Correct Answer:
A
Explanation: The 'RUN' instruction is used to execute commands in a Dockerfile during the image build process, allowing you to install packages or modify the file system.
Explanation: The 'RUN' instruction is used to execute commands in a Dockerfile during the image build process, allowing you to install packages or modify the file system.
6 What is the difference between CMD and ENTRYPOINT in a Dockerfile?
Correct Answer:
B
Explanation: The 'CMD' instruction provides default arguments for the 'ENTRYPOINT' instruction, and it can be overridden when the container is run.
Explanation: The 'CMD' instruction provides default arguments for the 'ENTRYPOINT' instruction, and it can be overridden when the container is run.
7 What does the EXPOSE instruction do in a Dockerfile?
Correct Answer:
C
Explanation: The 'EXPOSE' instruction informs Docker that the container will listen on the specified network ports at runtime, allowing for communication with other containers or services.
Explanation: The 'EXPOSE' instruction informs Docker that the container will listen on the specified network ports at runtime, allowing for communication with other containers or services.
8 Which of the following is NOT a valid instruction in a Dockerfile?
Correct Answer:
B
Explanation: There is no 'BUILD' instruction in a Dockerfile. Valid instructions include 'COPY', 'RUN', and 'FROM'.
Explanation: There is no 'BUILD' instruction in a Dockerfile. Valid instructions include 'COPY', 'RUN', and 'FROM'.
9 What is the purpose of the VOLUME instruction in a Dockerfile?
Correct Answer:
A
Explanation: The 'VOLUME' instruction is used to create a mount point with the specified path and to enable data persistence by allowing data to be stored outside the container.
Explanation: The 'VOLUME' instruction is used to create a mount point with the specified path and to enable data persistence by allowing data to be stored outside the container.
10 How can you specify build arguments in a Dockerfile?
Correct Answer:
A
Explanation: The 'ARG' instruction allows you to define variables that users can pass at build-time to the Dockerfile, enabling dynamic image builds.
Explanation: The 'ARG' instruction allows you to define variables that users can pass at build-time to the Dockerfile, enabling dynamic image builds.