Removing images (docker rmi) - Comparison with traditional VMs

I think the Docker for Absolute Beginner course would benefit from the below clarification under “Basic Docker commands” section:

Can a VM image be removed after the VM is created?

:white_check_mark: Yes — once a virtual machine (VM) is created and running, you can delete its base image without affecting the VM.


:mag: Why?

In virtualization platforms like VirtualBox, VMware, Hyper-V, or cloud platforms like AWS EC2:

  • A VM image (e.g., .vmdk, .iso, or an AMI) is just a template to create the VM.
  • Once the VM is created, it has its own virtual disk, separate from the original image.

So:

  • The VM becomes self-contained.
  • The image is no longer needed for that VM to run.
  • You can delete the original image, and the VM will keep working.

:pushpin: Example:

  1. You download ubuntu.iso
  2. You create a new VM using this ISO
  3. The VM creates its own disk (e.g., ubuntu-disk.vdi)
  4. You can delete ubuntu.iso, and the VM will still work

:arrows_counterclockwise: How Docker is different:

In Docker:

  • The image is still tightly linked to the container
  • A container depends on the image it was created from
  • You cannot delete the image until all containers based on it are removed