Docker for Data Engineers
Package pipelines and run local data stacks with Docker and Docker Compose: images, containers, volumes, networks and environment config.
Beginner · about 6 hours · difficulty 2/5
Learn first: Linux and the Command Line for Data Work, Production-Grade Python
Docker lets you run Postgres, Kafka, Airflow and your own pipeline code locally exactly as they run in production. Most tutorials, including the DE Zoomcamp, assume you can use it.
Core concepts
- Image: a packaged filesystem plus a start command, built from a
Dockerfile. - Container: a running instance of an image.
- Registry: where images are stored (Docker Hub, ECR, Artifact Registry).
- Volumes: persist data outside the container (so your Postgres data survives restarts).
- Networks: containers talk to each other by service name.
Dockerising a pipeline
- Start from a slim Python base image, copy the lock file first, install dependencies, then copy code. This order makes rebuilds fast thanks to layer caching.
- Pass configuration through environment variables; never bake secrets into images.
- One process per container; make the command parameterised (
python -m pipeline --date 2026-10-24).
Docker Compose
A docker-compose.yml defines a whole local stack (Postgres, pgAdmin, your extractor, MinIO) started with docker compose up. Great for portfolio projects that reviewers can run in one command.
Beyond Docker
In production, containers run on Kubernetes, ECS, Cloud Run or as tasks launched by an orchestrator. You do not need deep Kubernetes knowledge as a junior, but know what a pod is.
Pitfalls
- Huge images from full base images and leftover build files.
- Storing data inside a container without a volume and losing it on restart.
localhostconfusion: inside a container, localhost is the container itself, not your laptop.
You are ready to move on when your API extractor runs as a Docker image and a Compose file starts it alongside Postgres and MinIO with a single command.
Key concepts
- Images and containers
- Writing a Dockerfile
- Layer caching
- Volumes and networks
- Docker Compose
- Environment variables and secrets
- Container registries
- Kubernetes basics
Mini project
Write a Dockerfile for your API extractor and a docker-compose.yml that runs it with PostgreSQL and MinIO. Document in the README how anyone can clone the repo and run the whole stack with one command.
Check yourself
Your containerised script cannot connect to Postgres at localhost:5432 even though Postgres is running in Compose. Why, and what is the fix?
Free resources
- Docker get started (Docker)
- Docker Compose documentation (Docker)
- Docker roadmap (roadmap.sh)
- Data Engineering Zoomcamp (Docker module) (DataTalksClub)