Dockerfile Master: The Containerization Quiz Quiz

  1. Dockerfile Base Image

    Which Dockerfile instruction specifies the base image to use for building the container?

    1. IMAGE
    2. FROM
    3. BASE
    4. SOURCE
    5. USING
  2. COPY vs. ADD

    What is the primary difference between the COPY and ADD instructions in a Dockerfile?

    1. COPY only copies local files/directories, while ADD can also download files from URLs or extract archives.
    2. ADD only copies local files/directories, while COPY can also download files from URLs or extract archives.
    3. COPY is deprecated and ADD should be used instead.
    4. ADD is deprecated and COPY should be used instead.
    5. There is no functional difference between COPY and ADD.
  3. CMD Instruction

    Which Dockerfile instruction specifies the command to run when the container starts?

    1. RUN
    2. START
    3. EXEC
    4. CMD
    5. LAUNCH
  4. WORKDIR Instruction

    What is the purpose of the WORKDIR instruction in a Dockerfile?

    1. Specifies the directory where the Dockerfile is located.
    2. Sets the working directory for subsequent instructions, like RUN, CMD, COPY, and ADD.
    3. Defines a volume mount point within the container.
    4. Configures environment variables for the container.
    5. Specifies a temporary directory for build artifacts.
  5. RUN Instruction

    What is the primary purpose of the RUN instruction in a Dockerfile?

    1. To execute a command inside the container during the build process.
    2. To execute a command when the container is started.
    3. To define environment variables.
    4. To copy files from the host machine to the container.
    5. To expose a port on the container.
  6. Dockerfile Layering

    How does Docker utilize layers when building an image from a Dockerfile?

    1. Each instruction creates a new layer, caching intermediate results.
    2. All instructions are combined into a single layer.
    3. Only RUN instructions create layers.
    4. Only COPY and ADD instructions create layers.
    5. Layers are only created for instructions that modify the file system.
  7. ENTRYPOINT vs. CMD

    What is the difference between ENTRYPOINT and CMD in a Dockerfile?

    1. ENTRYPOINT specifies the executable, and CMD provides default arguments. CMD arguments can be overridden when running the container.
    2. CMD specifies the executable, and ENTRYPOINT provides default arguments. ENTRYPOINT arguments can be overridden when running the container.
    3. ENTRYPOINT and CMD are interchangeable; they perform the same function.
    4. ENTRYPOINT is used for applications, and CMD is used for scripts.
    5. CMD is used for applications, and ENTRYPOINT is used for scripts.
  8. Environment Variables

    Which instruction is used to define environment variables within a Dockerfile?

    1. ENV
    2. VARIABLE
    3. EXPORT
    4. SET
    5. ENVIRONMENT
  9. EXPOSE Instruction

    What is the purpose of the EXPOSE instruction in a Dockerfile?

    1. To publish a port to the host machine.
    2. To document which port the application will use, without actually publishing it.
    3. To specify a range of ports to be used by the application.
    4. To automatically forward traffic to the container.
    5. To configure firewall rules for the container.
  10. Ignoring Files (.dockerignore)

    What is the purpose of a `.dockerignore` file in the context of Dockerfiles?

    1. To specify files and directories that should be excluded from the build context.
    2. To specify files and directories that should be included in the build context.
    3. To define environment variables for the build process.
    4. To specify dependencies that should be installed during the build process.
    5. To configure logging for the build process.