Docker Basics: Containers vs Virtual Machines Quiz Quiz

Explore key differences and core concepts of containers and virtual machines with this quiz focused on Docker basics. Assess your understanding of architecture, resource management, deployment, and security in containerization versus virtualization.

  1. Container vs Virtual Machine Architecture

    Which statement best describes a fundamental difference in architecture between containers and virtual machines?

    1. Virtual machines always require less memory than containers.
    2. Virtual machines and containers both require a separate instance of the operating system for every application.
    3. Containers require hardware virtualization extensions, but virtual machines do not.
    4. Containers share the host system's kernel, while virtual machines run their own separate operating systems.

    Explanation: Containers share the host operating system's kernel and isolate applications at the process level, making them lightweight. In contrast, virtual machines include a full guest operating system and virtualize the hardware, leading to greater resource use. The statement about virtual machines always using less memory is incorrect; they typically use more. Hardware virtualization is a requirement for virtual machines, not containers. Not every application needs its own OS instance in either approach.

  2. Resource Efficiency

    A development team wants to maximize the number of isolated app environments on a single server. Which technology generally provides higher density, containers or virtual machines?

    1. Neither can provide isolated environments
    2. Virtual Machines
    3. Containers
    4. Both offer the same density

    Explanation: Containers are lightweight because they share the host’s kernel and avoid the overhead of running separate operating systems, allowing for greater density on a single host. Virtual machines require more resources due to duplicating the OS, reducing the number of environments that can run concurrently. Both do not provide the same density, and the idea that neither offers isolated environments is false—both do, but containers are more resource-efficient.

  3. Portability

    Why are containers often considered more portable than virtual machines in deploying applications?

    1. Containers package the application and its dependencies in a standard unit, making moves across environments easier.
    2. Virtual machines do not support packaging dependencies with applications.
    3. Virtual machines can only run on physical hardware, not in the cloud.
    4. Containers always contain a full operating system image.

    Explanation: Containers include the application and its dependencies, excluding the operating system, which allows for consistent runs across different systems. The second option is incorrect—containers do not contain a full OS image. The third option wrongly states that virtual machines cannot run in the cloud; they can. The last distractor is incorrect because virtual machines can package dependencies, just less efficiently and uniformly than containers.

  4. Startup Time

    Which technology typically offers faster start-up times, containers or virtual machines, and why?

    1. Virtual machines, because they use direct hardware access.
    2. Both have nearly identical start-up times due to similar underlying structures.
    3. Virtual machines, because containers require a hypervisor.
    4. Containers, because they avoid booting a full operating system image.

    Explanation: Containers launch quickly since they only start their isolated processes using the host OS, without needing to boot an entire OS image. Virtual machines must initialize a complete operating system, resulting in longer start-up times. The statement about virtual machines having direct hardware access is misleading since both use abstraction layers. Containers do not require a hypervisor, and the startup times are not nearly identical.

  5. Security Isolation

    In terms of security isolation, which potential risk is often higher in containers compared to virtual machines?

    1. Virtual machines share the same process space, creating more vulnerabilities.
    2. Containers always run slower than virtual machines for security reasons.
    3. Virtual machines have less overhead, increasing the attack surface.
    4. Containers may have increased risk of kernel-level attacks due to the shared kernel with the host.

    Explanation: Because containers share the host kernel, a vulnerability in the kernel can impact all containers, increasing the risk of kernel-level attacks. Containers do not inherently run slower than virtual machines, so the second option is false. Virtual machines, having more overhead, actually isolate systems better, not worse. Virtual machines do not share process space like containers, so the last distractor is incorrect.