- LPU MCA Semester 1
- CAP470
- Unit 4
CAP470 · Unit 4: Containers
Containers versus virtual machines
10 practice questions · in the MTE and ETE syllabus
Key points
- Containers share a kernel, VMs have their own
- Containers are lighter, faster and denser
- VMs give stronger isolation and OS variety
- Containers inside VMs combine both strengths
Containers virtualize the operating system, while VMs virtualize the hardware.
| Aspect | Container | Virtual machine |
|---|---|---|
| Kernel | shares the host kernel | own guest kernel |
| Size | megabytes | gigabytes |
| Startup | seconds or less | tens of seconds to minutes |
| Density | very high | lower |
| Isolation | process-level, weaker | hardware-level, stronger |
| Different OS | no, must match host kernel | yes |
Use containers for many small, fast-starting, scalable services and VMs for strong isolation, different operating systems or untrusted code. Many clouds run containers inside VMs to combine VM isolation with container portability, for example running each customer's containers in a separate VM.
Exam trap: containers trade some isolation for density and speed, so shared-kernel containers are not the safest boundary for untrusted code.
Try two questions
Which comparison between containers and VMs is correct?
- Containers virtualize the hardware, while VMs virtualize the operating system
- Both virtualize only the network cards
- Neither virtualizes anything at all
- Containers virtualize the operating system, while VMs virtualize the hardware
Show the answer
D. A VM abstracts hardware for a guest OS, and a container abstracts the OS for its processes.
Why not A: This reverses the two.
Why not B: Neither is limited to network cards.
Why not C: Both provide some level of virtualization.
A start-up needs thousands of short-lived tasks to launch within a second. Which technology fits best?
- Virtual machines that each boot a guest OS
- Containers
- Physical servers ordered for each task
- Manually installed software on one server
Show the answer
B. Containers start in seconds or less because they do not boot a guest OS.
Why not A: VM boot time is much longer.
Why not C: Ordering servers takes far too long.
Why not D: Manual installs cannot launch thousands of tasks within a second.