Bird
Raised Fist0
Dockerdevops~20 mins

Containers vs virtual machines in Docker - Practice Questions

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Container Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Difference in resource usage between containers and VMs

Which statement best describes the difference in resource usage between containers and virtual machines?

AVirtual machines share the host OS kernel and use fewer resources than containers, which run full guest OS instances.
BVirtual machines do not require any resources because they run on the host OS directly.
CContainers and virtual machines use the same amount of resources because both run full guest OS instances.
DContainers share the host OS kernel and use fewer resources than virtual machines, which run full guest OS instances.
Attempts:
2 left
💡 Hint

Think about what runs inside containers versus virtual machines.

💻 Command Output
intermediate
2:00remaining
Output of Docker command showing running containers

What is the output of the command docker ps when no containers are running?

Docker
docker ps
ACONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\nabc123 nginx "/bin/bash" 2 hours ago Up 2 hours 80/tcp webserver
BCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
CError: No containers found
DNo containers running
Attempts:
2 left
💡 Hint

Try running docker ps on a system with no running containers.

🔀 Workflow
advanced
3:00remaining
Steps to migrate an application from VM to container

Which sequence correctly describes the steps to migrate an application from a virtual machine to a Docker container?

A3,2,1,4
B2,1,3,4
C1,2,3,4
D1,3,2,4
Attempts:
2 left
💡 Hint

Think about the logical order from understanding the app to deployment.

❓ Troubleshoot
advanced
2:00remaining
Troubleshooting container networking issues

You have a container running a web server, but you cannot access it from your host machine. Which is the most likely cause?

AThe container port is not published to the host using <code>-p</code> option.
BThe container image is missing the web server software.
CThe Docker daemon is not running on the host.
DThe container is running in privileged mode.
Attempts:
2 left
💡 Hint

Check how ports are exposed from container to host.

✅ Best Practice
expert
2:30remaining
Best practice for container image size optimization

Which practice is best to minimize the size of a Docker container image?

AUse a minimal base image and remove unnecessary files during build.
BInstall all development tools inside the container for flexibility.
CUse multiple layers with large files to speed up builds.
DKeep all logs inside the container to track issues.
Attempts:
2 left
💡 Hint

Think about what makes images large and how to reduce that.

Practice

(1/5)
1. Which statement best describes the main difference between containers and virtual machines?
easy
A. Containers require more disk space than virtual machines.
B. Virtual machines are faster to start than containers.
C. Virtual machines share the host OS kernel, containers do not.
D. Containers share the host OS, while virtual machines run separate full OS instances.

Solution

  1. Step 1: Understand container architecture

    Containers share the host operating system kernel, making them lightweight and fast.
  2. Step 2: Understand virtual machine architecture

    Virtual machines run a full guest OS on top of a hypervisor, making them heavier and fully isolated.
  3. Final Answer:

    Containers share the host OS, while virtual machines run separate full OS instances. -> Option D
  4. Quick Check:

    Containers share OS, VMs run full OS [OK]
Hint: Containers share OS; VMs run full OS instances [OK]
Common Mistakes:
  • Thinking containers run full OS instances
  • Believing VMs share the host OS kernel
  • Assuming containers use more disk space
2. Which of the following is the correct command to list running Docker containers?
easy
A. docker ps
B. docker images
C. docker run
D. docker start

Solution

  1. Step 1: Identify command to list running containers

    The command docker ps shows all running containers.
  2. Step 2: Differentiate from other commands

    docker images lists images, docker run starts a container, and docker start restarts stopped containers.
  3. Final Answer:

    docker ps -> Option A
  4. Quick Check:

    List running containers = docker ps [OK]
Hint: Use 'docker ps' to see running containers [OK]
Common Mistakes:
  • Using 'docker images' to list containers
  • Confusing 'docker run' with listing
  • Using 'docker start' instead of listing
3. Given the following scenario: You start a Docker container and run uname -a inside it. What will this command output compared to running uname -a on a virtual machine?
medium
A. Both outputs will be identical because containers and VMs have the same kernel.
B. Both outputs will be completely unrelated to the host system.
C. The container's output shows the host kernel, VM shows its own kernel version.
D. The container shows a different kernel version than the host, VM shows host kernel.

Solution

  1. Step 1: Understand container kernel sharing

    Containers share the host OS kernel, so uname -a inside a container shows the host kernel version.
  2. Step 2: Understand VM kernel isolation

    Virtual machines run their own OS kernel, so uname -a inside a VM shows the VM's kernel version, which can differ from the host.
  3. Final Answer:

    The container's output shows the host kernel, VM shows its own kernel version. -> Option C
  4. Quick Check:

    Container shares kernel, VM has own kernel [OK]
Hint: Containers share kernel; VMs have separate kernels [OK]
Common Mistakes:
  • Assuming containers have separate kernels
  • Thinking VM shares host kernel
  • Believing outputs are identical always
4. You tried to run a Docker container but got an error saying the container cannot start due to kernel incompatibility. What is the most likely cause?
medium
A. The Docker daemon is not installed.
B. The container image requires a different kernel feature not supported by the host OS.
C. The container image is corrupted and cannot be loaded.
D. The container is trying to run a full OS which is not allowed.

Solution

  1. Step 1: Analyze kernel incompatibility error

    Containers rely on the host kernel. If the container needs kernel features missing on the host, it cannot start.
  2. Step 2: Rule out other causes

    Docker daemon missing causes different errors; corrupted images cause load errors; containers can run full OS but share kernel.
  3. Final Answer:

    The container image requires a different kernel feature not supported by the host OS. -> Option B
  4. Quick Check:

    Kernel features mismatch causes container start failure [OK]
Hint: Kernel mismatch blocks container start, check host features [OK]
Common Mistakes:
  • Assuming Docker daemon missing causes kernel errors
  • Blaming image corruption for kernel issues
  • Thinking containers run full OS independently
5. You want to deploy an application that requires full OS isolation for security but also needs to start quickly and use minimal resources. Which approach is best?
hard
A. Use containers with additional security layers like SELinux or AppArmor.
B. Use containers for speed and efficiency but accept less isolation.
C. Use virtual machines for full isolation despite slower startup and higher resource use.
D. Use virtual machines with lightweight OS images to speed up startup.

Solution

  1. Step 1: Understand isolation vs speed tradeoff

    Virtual machines provide full OS isolation but are slower and heavier; containers are fast but share kernel.
  2. Step 2: Consider enhanced container security

    Adding security layers like SELinux/AppArmor to containers improves isolation while keeping speed and resource benefits.
  3. Step 3: Evaluate other options

    Using VMs sacrifices speed; lightweight VMs help but still slower than containers; plain containers lack full isolation.
  4. Final Answer:

    Use containers with additional security layers like SELinux or AppArmor. -> Option A
  5. Quick Check:

    Secure containers balance isolation and speed [OK]
Hint: Secure containers with extra layers for isolation and speed [OK]
Common Mistakes:
  • Choosing VMs ignoring startup speed
  • Using plain containers without security layers
  • Assuming lightweight VMs match container speed
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard