Last updated: May 2026
Azure ContainersBeginnerAZ-204⏱ 11 min read

What are Containers?

Containers are a lightweight way to package and run applications. A container bundles your application code, runtime, libraries, and configuration into a single portable unit that runs consistently anywhere — your laptop, a test server, or Azure. They are faster to start than VMs, use far less memory, and make "it works on my machine" a thing of the past.

What you'll learn What a container is and how it works · Containers vs Virtual Machines · Container images and layers · Docker — the container runtime · The container lifecycle · Why containers matter for cloud · Key terminology — image, container, registry, Dockerfile

What is a Container?

A container is an isolated process running on a host OS. Unlike a VM which virtualises the entire hardware stack, a container shares the host OS kernel but has its own isolated filesystem, network, and process space. This makes containers extremely lightweight — they start in seconds, use megabytes of memory, and can run thousands on a single host.

ℹ️
The Key Insight A container packages everything an application needs to run — code, runtime, dependencies, config — into one portable unit. The same container image runs identically on a developer laptop, CI server, and production cloud. No more environment-specific bugs.

Containers vs Virtual Machines

Virtual MachineContainer
IncludesFull OS + applicationApplication + dependencies only
SizeGigabytesMegabytes
Startup timeMinutesSeconds (often milliseconds)
OS kernelOwn kernel per VMShared host kernel
IsolationStrong — hardware-levelGood — process-level
DensityTens per hostHundreds or thousands per host
Best forFull OS control, legacy apps, strong isolationMicroservices, scaling, consistent deployments

Container Images and Layers

A container image is a read-only template used to create containers. Images are built in layers — each instruction in a Dockerfile adds a new layer. Layers are cached and shared between images, making storage efficient.

  • Base layer — The OS foundation (e.g., Ubuntu, Alpine, Windows Server Core)
  • Dependency layers — Runtime, packages, libraries
  • Application layer — Your actual code
  • Config layer — Environment variables, exposed ports

The Dockerfile

A Dockerfile is a text file with instructions to build a container image:

DockerfileSimple Node.js app container
# Start from official Node.js base image
FROM node:20-alpine

# Set working directory inside container
WORKDIR /app

# Copy package files and install dependencies
COPY package*.json ./
RUN npm install --production

# Copy application code
COPY . .

# Expose port 3000
EXPOSE 3000

# Command to run when container starts
CMD ["node", "server.js"]

Container Lifecycle

StageCommandDescription
Build imagedocker build -t myapp:v1 .Create image from Dockerfile
Push to registrydocker push myregistry/myapp:v1Upload image to container registry
Pull imagedocker pull myregistry/myapp:v1Download image from registry
Run containerdocker run -p 3000:3000 myapp:v1Start a container from the image
Stop containerdocker stop mycontainerGracefully stop a running container
Remove containerdocker rm mycontainerDelete a stopped container

Why Containers Matter

  • Consistency — Same image runs identically in dev, test, and production
  • Speed — Start in milliseconds vs minutes for VMs
  • Density — Pack hundreds of containers on one host
  • Microservices — Each service in its own container, independently deployable
  • CI/CD — Build once, deploy anywhere — perfect for automated pipelines
  • Portability — Run on any cloud, any on-premises server, any developer machine

Key Terminology

TermDefinition
ImageRead-only template — the blueprint for a container
ContainerA running instance of an image
DockerfileInstructions to build an image
RegistryStorage for container images (Docker Hub, Azure Container Registry)
TagVersion label for an image (e.g., myapp:v1, myapp:latest)
DockerThe most popular container runtime
OrchestratorTool to manage many containers (Kubernetes, Azure Container Apps)
💡
AZ-204 Exam Tip Know that containers share the host OS kernel (unlike VMs). Know that an image is read-only — containers are running instances of images. Know that a Dockerfile builds an image. Know that a registry stores images. Know that containers start in seconds, not minutes.
📝 Practice Questions
Click an option to check your answer.
Q1. What is the key difference between a container and a virtual machine?
A — Containers include a full operating system; VMs do not
B — Containers share the host OS kernel; VMs each have their own full OS
C — Containers are slower than VMs but more isolated
D — Containers only run on Linux; VMs run on any OS
Q2. What is a container image?
A — A running instance of an application
B — A read-only template used to create containers
C — A text file with instructions to build a container
D — A storage location for container files
Q3. What file contains the instructions to build a container image?
A — Dockerfile
B — docker-compose.yml
C — manifest.yaml
D — container.json
Q4. Where are container images stored and shared?
A — Azure Blob Storage
B — A container registry (e.g., Docker Hub, Azure Container Registry)
C — Azure File Storage
D — GitHub repository
Q5. How long does a container typically take to start compared to a VM?
A — Seconds or milliseconds vs minutes for a VM
B — About the same time as a VM
C — Longer than a VM — containers have more to initialise
D — Hours — containers require extensive setup
Comments
Disclaimer: RedKite Cloud is an independent educational resource and is not affiliated with Microsoft Corporation.