Roadmap › 3. Cloud & DevOps › Step 35
Dk

Docker & Containers

Containers vs VMs, images and layers, Dockerfile for .NET, multi-stage builds, volumes, networks, Docker Compose, registries, security, debugging and production best practices.
What it is & where it is used

Docker packages an application with everything it needs (runtime, libraries, config) into a container image that runs the same on a laptop, CI server or cloud. A container is a running instance of an image — an isolated process that shares the host's OS kernel.

Virtual machineContainer
IsolationFull guest OS on a hypervisorProcess isolation via kernel namespaces + cgroups
SizeGBsMBs
Start timeMinutesSeconds or less
DensityFew per hostMany per host
OSAny guest OSShares host kernel (Linux containers on Linux; Windows containers on Windows)

Key pieces: Docker Engine (daemon dockerd + CLI), images, containers, Dockerfile, registries (Docker Hub, Azure Container Registry, GitHub Container Registry), volumes, networks, Docker Compose. Standards: the OCI (Open Container Initiative) image and runtime specs; low-level runtimes containerd and runc.

Versions & history
YearMilestone
2008Linux Containers (LXC)
2013Docker open-sourced by dotCloud (PyCon demo)
2014Docker 1.0; Docker Compose (from Fig)
2015Open Container Initiative (OCI) founded; Docker Swarm
2016Docker for Mac/Windows; Windows Server containers
2017Multi-stage builds (17.05); Moby project; containerd donated to CNCF; version scheme YY.MM
2019Docker Enterprise sold to Mirantis
2020BuildKit default path; Compose Specification
2021Docker Desktop requires a paid subscription for larger companies (>250 employees or >$10M revenue)
2022Kubernetes removes dockershim (v1.24) — Docker-built images still run fine
2023Docker Compose v2 (docker compose) replaces docker-compose; Docker Scout; Docker Init
2024–2025Docker Engine 27/28: Docker Build Cloud, Docker Desktop AI features, hardened images

.NET images: mcr.microsoft.com/dotnet/sdk (build), aspnet (ASP.NET Core runtime), runtime (console apps), runtime-deps (self-contained/AOT). Since .NET 8 they run as a non-root app user and default to port 8080.

Lifecycle

Container lifecycle:

docker create → Created → docker start → Running → docker pause → Paused → docker unpause → Running → docker stop (SIGTERM, then SIGKILL after 10 s) → Exited → docker start again or docker rm → Removed. docker run = create + start. docker kill sends SIGKILL immediately. Restart policies: no, on-failure, always, unless-stopped.

Image lifecycle: write Dockerfile → docker build (each instruction creates a cached layer) → docker tag → docker push to a registry → docker pull on the target → docker run → update → rebuild/retag → prune old images.

Dev-to-prod flow: code → Dockerfile → CI builds and tests the image → scan for vulnerabilities → push with an immutable tag (git SHA) → deploy to Kubernetes/Azure Container Apps/App Service → monitor.

Tools used to develop
ToolUse
Docker Desktop (Windows/Mac), Docker Engine (Linux)Run containers locally
Podman, Rancher Desktop, colimaDocker alternatives
Docker ComposeMulti-container apps for dev/test
BuildKit / docker buildxFast, multi-platform builds
Visual Studio container tools, VS Code Dev Containers / Container ToolsBuild, debug in containers
.NET SDK container publishing (dotnet publish -t:PublishContainer)Build images without a Dockerfile
Azure Container Registry, Docker Hub, GHCRRegistries
Docker Scout, Trivy, Grype, Microsoft Defender for ContainersVulnerability scanning
HadolintDockerfile linting
DiveInspect image layers
TestcontainersReal dependencies in integration tests