From Beginner to Expert: Your Path from Docker to Kubernetes Quiz

Explore essential concepts and best practices as you transition from using Docker for single containers to orchestrating applications with Kubernetes. Build your foundational knowledge of Docker, Docker Compose, and Kubernetes for efficient container management.

  1. Understanding Docker Fundamentals

    What command is used to create and start a container from an image named 'hello-world'?

    1. docker pull hello-world
    2. docker build hello-world
    3. docker run hello-world
    4. docker start hello-world

    Explanation: The correct command to create and start a container from the 'hello-world' image is 'docker run hello-world'. 'docker start' is used to start a stopped container, not create a new one. 'docker build' is for building images from a Dockerfile, and 'docker pull' only downloads the image without running it.

  2. Dockerfile Concepts

    Which instruction in a Dockerfile sets the working directory inside the container for subsequent commands?

    1. CMD
    2. RUN
    3. WORKDIR
    4. COPY

    Explanation: The WORKDIR instruction sets the working directory for future instructions such as RUN, CMD, and COPY. CMD sets the default command to run, COPY copies files into the container, and RUN executes commands during the build process.

  3. Multi-Container Applications and Docker Compose

    How does Docker Compose allow services defined in a docker-compose.yml file to communicate by default?

    1. By mounting a shared volume
    2. They share a default network
    3. Through manually specified IP addresses
    4. By exposing all ports to the host

    Explanation: By default, Docker Compose creates a dedicated network for the services, allowing containers to communicate easily. Shared volumes are mainly for data sharing, not communication. Manual IP configuration is unnecessary due to service discovery. Exposing ports is used for host access, not inter-container communication.

  4. Scaling Services in Docker Compose

    Which command would you use to scale the 'web' service to three instances using Docker Compose?

    1. docker-compose run web --replicas=3
    2. docker-compose scale web 3
    3. docker scale web=3
    4. docker-compose up --scale web=3

    Explanation: 'docker-compose up --scale web=3' correctly scales the 'web' service to three instances. The 'docker scale' command does not exist. 'docker-compose scale' is outdated and not recommended for modern Compose versions. '--replicas' is not a parameter for docker-compose run.

  5. Kubernetes Orchestration Basics

    What is the purpose of a Kubernetes Deployment in managing containerized applications?

    1. It manages the desired state and updates of application replicas
    2. It provides persistent storage for containers
    3. It serves as a service to expose containers to a network
    4. It defines resource quotas for each namespace

    Explanation: A Kubernetes Deployment is responsible for maintaining the desired replica count and performing controlled updates to applications. Persistent storage is managed by PersistentVolume or PersistentVolumeClaim. Services handle networking and exposure, while resource quotas are set separately in Kubernetes.