docker

Docker, Containers, Images & Virtual Machines

Docker, Containers, Images & Virtual Machines

By Shubhankar Tripathi • • 5 min read

Introduction


What problem is Docker solving?

Docker packages an application and its required dependencies into a containerized environment so that the application can be run consistently across environments.

  • Docker is an open platform for developing, shipping, and running applications.
  • Package the application and its dependencies together, then run that package as a container.


What Is a Container?

A container is a runnable instance of a container image.

Docker's current documentation describes a container as an isolated process with the files it needs to run. Containers can be independently managed and can share the host kernel when using the Linux container model.

docker run nginx

Conceptually:

nginx Image
     │
     │ docker run
     ▼
nginx Container
     │
     ▼
Nginx Process

What Is a Container Image?

A container image is a standardized package containing the files required to run an application.

For example, a Python application image could contain:

Python runtime
     +
Python packages
     +
Application code
     +
Configuration
     +
Required system libraries

Docker describes images as immutable and layered. Each layer represents filesystem changes that add, modify, or remove files.

A simplified image might look like:

┌──────────────────────────────┐

│ Application Code             

├──────────────────────────────┤

│ Python Dependencies          

├──────────────────────────────┤

│ Python Runtime               

├──────────────────────────────┤

│ Base Image                   

└──────────────────────────────┘


Image vs Container

This is one of the most important distinctions for beginners.

ConceptImageContainer
PurposePackage applicationRun application
StateImmutableRuntime state can change
ExecutionDoes not run by itselfRuns a process
StorageImage layersImage + writable container layer
RelationshipTemplateInstance
Examplenginx:latestmy-nginx

What Is a Virtual Machine?

A virtual machine is a virtualized computer system running on a physical or virtualized host.

A simplified architecture is:

Physical Hardware
Hypervisor
VM 1VM 1
Guest OSGuest OS
ApplicationApplication

A VM has its own operating-system environment, including its kernel.

Docker's documentation describes a VM as an entire operating system with its own kernel, drivers, programs, and applications.


Why Containers Can Be Lightweight

 A VM typically includes an entire guest OS environment.

A container does not need to package another complete Linux kernel when running as a Linux container on a Linux host.

Container

Application
   ↓
Container filesystem
   ↓
Container isolation
   ↓
Host Linux Kernel

This is one reason containers can be lightweight compared with full VMs.

Docker's documentation states that multiple containers can share the host kernel, allowing more applications to run on the same infrastructure in suitable workloads.

Important: lightweight does not mean "no isolation." Containers use kernel-level isolation mechanisms, and their security depends on the kernel, container configuration, Docker daemon, and other controls.