Docker Overview¶
Docker is a containerization platform that packages applications with their dependencies into isolated, portable units called containers. This enables consistent behavior across different environments—from development to production.
What is Docker?¶
Docker uses containerization to solve the "it works on my machine" problem. Instead of shipping source code or applications that depend on the host system's specific configuration, Docker bundles everything together:
- Application code
- Runtime environment
- System libraries
- Dependencies
- Configuration files
Containers vs Images¶
Images¶
An image is a blueprint or template—a read-only snapshot containing: - Base OS filesystem - Application code - Dependencies - Environment variables - Configuration
Think of it like a class definition in programming.
| Aspect | Description |
|---|---|
| Storage | Stored on disk, reusable |
| Size | Several MB to GB |
| Mutability | Read-only, immutable |
| Registry | Pushed to Docker Hub, registries |
| Creation | Built from Dockerfile |
Containers¶
A container is a running instance of an image—a lightweight, isolated process environment.
Think of it like an object instantiated from a class.
| Aspect | Description |
|---|---|
| Storage | Lives in memory, temporary layer on top of image |
| Size | Only stores changes from image |
| Mutability | Can be modified while running |
| Lifecycle | Created, started, stopped, removed |
| Isolation | Own filesystem, network, processes |
Visual Comparison¶
Image (Blueprint) Container (Running Instance)
├── Base OS (Alpine) ├── Image Layer (read-only)
├── Python Runtime ├── Container Layer (writable)
├── Dependencies ├── Filesystem
├── App Code ├── Network Interface
└── Config Files └── Process ID (PID)
Multiple containers can Each container is
run from one image independent & isolated
Why Use Docker?¶
1. Consistency¶
Same environment everywhere—development, testing, production.
Without Docker:
Dev: Python 3.9, PostgreSQL 12, Ubuntu 20.04
Test: Python 3.10, PostgreSQL 13, CentOS 8
Prod: Python 3.8, PostgreSQL 11, Ubuntu 18.04
❌ Different behaviors, bugs in prod
With Docker:
Dev: Docker image with exact versions
Test: Same Docker image
Prod: Same Docker image
✓ Predictable behavior everywhere
2. Isolation¶
Each container has its own: - Filesystem - Network namespace - Process space - Environment variables
Prevents conflicts between applications.
3. Scalability¶
Spin up multiple identical containers instantly for load balancing:
docker run myapp:1.0 # Instance 1
docker run myapp:1.0 # Instance 2
docker run myapp:1.0 # Instance 3
4. Lightweight & Fast¶
- Containers share the host OS kernel (not full OS like VMs)
- Startup time: milliseconds
- Memory overhead: minimal
- Ideal for microservices architecture
5. Portability¶
Once Dockerized, an application runs on: - Local machine - Cloud providers (AWS, GCP, Azure) - Kubernetes clusters - On-premises servers
Without modification.
6. Development Efficiency¶
# Instead of complex setup guide:
git clone repo
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
...
# Just run:
docker-compose up
Common Use Cases¶
| Use Case | Why Docker? |
|---|---|
| Microservices | Each service in own container, easy to scale/update |
| CI/CD Pipelines | Consistent build/test environments |
| Database Development | Spin up PostgreSQL, MongoDB without installation |
| Multi-version Testing | Test against Python 3.8, 3.9, 3.10 simultaneously |
| Team Onboarding | New developers: docker-compose up instead of 30-minute setup |
| Production Deployment | Guaranteed consistency from dev to prod |
Docker Architecture¶
┌─────────────────────────────────────────┐
│ Docker Client (CLI) │
│ $ docker run, build, push, etc. │
└────────────┬────────────────────────────┘
│
┌────────────▼────────────────────────────┐
│ Docker Daemon │
│ - Manages images & containers │
│ - Manages networks & volumes │
│ - Executes containers │
└────────────┬────────────────────────────┘
│
┌────────────▼────────────────────────────┐
│ Container Runtime (containerd) │
│ - Low-level container execution │
└────────────┬────────────────────────────┘
│
┌────────────▼────────────────────────────┐
│ Host OS Kernel │
│ - cgroups (resource limits) │
│ - namespaces (isolation) │
└─────────────────────────────────────────┘
Quick Facts¶
- Year Released: 2013
- Creator: Solomon Hykes (dotCloud)
- Type: Open source containerization platform
- Written in: Go
- License: Docker Community Edition (free), Docker Enterprise (paid)
- Standard: Implements OCI (Open Container Initiative) standards
Next Steps¶
- Learn Docker CLI commands
- Follow Docker best practices
- See Docker tutorials for hands-on guides
For questions, see Contributing Guide