Docker
Container platform that packages applications with all dependencies into portable, consistent units that run identically in any environment.
seed#docker#containers#devops#packaging#portability#images
What it is
Docker is a platform that allows packaging applications into containers — lightweight units that include the code, runtime, libraries, and configuration needed to run. A container runs identically on your laptop, in CI/CD, and in production.
Key concepts
| Concept | Function | Example |
|---|---|---|
| Image | Immutable template with the filesystem | node:22-alpine, custom image |
| Container | Running instance of an image | docker run my-app |
| Dockerfile | Recipe for building an image | FROM, COPY, RUN, CMD |
| Registry | Image repository | Docker Hub, ECR, GHCR |
| Volume | Persistent storage outside the container | Database data, uploads |
Basic Dockerfile
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]Docker vs VMs
| Aspect | Docker | VM |
|---|---|---|
| Overhead | Minimal (shares kernel) | High (full OS) |
| Startup | Seconds | Minutes |
| Size | MBs | GBs |
| Isolation | Process | Hardware |
Best practices
- Use official and minimal base images (alpine)
- Multi-stage builds for small images
- Don't run as root
- One process per container
- .dockerignore to exclude unnecessary files
Why it matters
Docker standardized application packaging. A container works the same in development, CI, and production. This consistency eliminated an entire category of environment bugs and enabled practices like CI/CD, microservices, and immutable infrastructure.
References
- Docker Documentation — Official documentation.
- Dockerfile Best Practices — Official guide.
- Docker Overview — Docker, 2024. Official Docker documentation.