Lesson content
Read, practise, then check your understanding
Introduction to Docker
Docker packages an application and its runtime dependencies into an image, then starts that image as an isolated container process. The same versioned image can move from a developer machine to CI and production, reducing differences between environments.
Core ideas
- A container shares the host kernel and isolates processes, mounts, users, and networking with operating-system features.
- A virtual machine emulates hardware and boots a guest kernel, usually providing a stronger but heavier boundary.
- An image is immutable and layered; a container adds a writable layer and runtime configuration.
- Open Container Initiative (OCI) specifications support interoperability between image and runtime tools.
How it works
The Docker client asks a daemon to pull or build an image and create a container. The runtime establishes namespaces, resource controls, filesystems, environment variables, mounts, and networking before starting the configured process. A container is not a miniature server: it should have a clear primary process and replaceable state.
Command or configuration example
# Start an isolated web process and publish host port 8080
docker run --name demo --rm -p 8080:80 nginx:1.27-alpine
# In another terminal, inspect its identity and configuration
docker ps
docker inspect demo
Run examples first in a disposable environment. Replace image names, versions, credentials, ports, paths, and resource values with reviewed settings appropriate to your system.
Production guidance
- Use containers for reproducible application processes, not as a substitute for every VM or security boundary.
- Keep durable data outside the writable container layer.
- Pin and scan images, limit privileges and resources, and record which image digest is deployed.
The chapter quiz follows this lesson and checks the concepts as well as the operational tradeoffs.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.