Docker Container Mastery Quiz Quiz

  1. Choosing the Right Command

    Which Docker command is used to build an image from a Dockerfile?

    1. docker run
    2. docker start
    3. docker build
    4. docker compose up
    5. docker image make
  2. Port Mapping

    How do you map a port on your host machine to a port inside a Docker container?

    1. Using the -p flag followed by host_port:container_port
    2. Using the -m flag followed by host_port:container_port
    3. By specifying port mappings in the Dockerfile
    4. By setting the PORT environment variable
    5. Using the --port flag
  3. Detached Mode

    Which flag allows you to run a Docker container in detached mode, meaning it runs in the background?

    1. -d
    2. -bg
    3. -detach
    4. -b
    5. --background
  4. Docker Compose

    What is the primary purpose of Docker Compose?

    1. To build a single Docker image
    2. To orchestrate multi-container Docker applications
    3. To monitor Docker container resource usage
    4. To manage Docker volumes
    5. To create Docker networks
  5. Dockerfile Instruction: EXPOSE

    What does the EXPOSE instruction in a Dockerfile do?

    1. Exposes a port on the host machine
    2. Documents the port the container listens on, but does not actually publish the port
    3. Maps a port directly to the host machine for external access
    4. Encrypts the port for secure communication
    5. Opens a specific port for remote debugging
  6. Docker Volume

    What is the purpose of using Docker volumes?

    1. To store container logs permanently
    2. To persist data generated by the container even after the container is stopped or removed
    3. To improve the container's network performance
    4. To reduce the size of the Docker image
    5. To encrypt data inside the container
  7. Docker Networking

    By default, how can containers communicate with each other within the same Docker network?

    1. Using their container names as hostnames
    2. Only through exposed ports
    3. They can't communicate by default without additional configuration
    4. Using the host machine's IP address
    5. Via shared volumes only
  8. ENV Instruction in Dockerfile

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

    1. To set environment variables within the container
    2. To encrypt environment variables
    3. To expose environment variables to the host machine
    4. To limit environment variables
    5. To automatically update environment variables
  9. Docker Image Layers

    Why are Docker images built in layers?

    1. To minimize image size and improve build times through caching
    2. To improve container security
    3. To simplify image deployment
    4. To enable easier image versioning
    5. To make images more portable
  10. Removing a Docker Container

    Which command removes a stopped Docker container?

    1. docker stop
    2. docker rm
    3. docker remove
    4. docker delete
    5. docker kill