Containerizing Data Pipelines with Docker & Docker Compose
Package extractors and workers in images and orchestrate local stacks with Compose for reproducible runs.
In plain words
Lock runtime and copy only app artifacts. Next, compose services, networks, ports, and volumes. Finally, logs, exit codes, persisted test output, cleanup.
Think of it like…
The image is a sealed delivery kit and Compose is the assembly plan; without health checks, one kit may be opened before the required database kit is ready.
Where you’ve seen it
A Compose service ingester waits on Postgres's pg_isready health check, reads DATABASE_URL_FILE, mounts ./output explicitly, and uses an immutable etl:git-sha image built in CI.
Words you’ll hear
- Docker
- An immutable layered executable artifact built from a Dockerfile for a consistent pipeline runtime.
- Compose
- A declarative local orchestrator for multiple containers, their networks, health checks, and development volumes.
- Reproducibility
- The ability to create equivalent runtime behavior from committed source and pinned inputs on another machine.
- Operational boundary
- Using
latest, running as root, copying local credentials into an image, or mounting a writable data directory with assumptions about host permissions makes a reproducible Compose run fail in CI. Pin image digests or versions, use multi-stage minimal images, run a non-root UID, declare health checks and dependencies, and inject secrets at runtime rather than baking them into layers.
Visual diagram
Theory & deep dive
Docker: the working mechanism
A Docker image packages a pinned runtime and pipeline dependencies, while Compose declares a local multi-service topology-database, object store, broker, and worker-with networks and volumes.
Lock runtime and copy only app artifacts. Compose services, networks, ports, and volumes, then health-gated dependencies and one command per service; this exposes the state governed by Reproducibility.
A Compose service ingester waits on Postgres's pg_isready health check, reads DATABASE_URL_FILE, mounts ./output explicitly, and uses an immutable etl:git-sha image built in CI.
Containerizing Data Pipelines with Docker & Docker Compose: failure mode and production response
Using latest, running as root, copying local credentials into an image, or mounting a writable data directory with assumptions about host permissions makes a reproducible Compose run fail in CI.
Pin image digests or versions, use multi-stage minimal images, run a non-root UID, declare health checks and dependencies, and inject secrets at runtime rather than baking them into layers. Track Image tag as "immutable Git SHA or signed digest", and make Health status visible to the dataset owner.
How it works, step by step
Step 1 of 41. Build
Lock runtime and copy only app artifacts. A Docker image packages a pinned runtime and pipeline dependencies, while Compose declares a local multi-service topology-database, object store, broker, and worker-with networks and volumes.
- Image tag
- immutable Git SHA or signed digest
- Compose
- A declarative local orchestrator for multiple containers, their networks, health checks, and development volumes.
When to use it & trade-offs
What it is
A Docker image packages a pinned runtime and pipeline dependencies, while Compose declares a local multi-service topology-database, object store, broker, and worker-with networks and volumes. A Compose service ingester waits on Postgres's pg_isready health check, reads DATABASE_URL_FILE, mounts ./output explicitly, and uses an immutable etl:git-sha image built in CI.
Why it matters: Using latest, running as root, copying local credentials into an image, or mounting a writable data directory with assumptions about host permissions makes a reproducible Compose run fail in CI. Pin image digests or versions, use multi-stage minimal images, run a non-root UID, declare health checks and dependencies, and inject secrets at runtime rather than baking them into layers.
When to reach for it
- Package extractors and workers in images and orchestrate local stacks with Compose for reproducible runs.
- Choose Docker because it provides this capability: An immutable layered executable artifact built from a Dockerfile for a consistent pipeline runtime.
- Keep evidence for Image tag at "immutable Git SHA or signed digest" so the last production stage-Verify - logs, exit codes, persisted test output, cleanup-remains testable.
When to avoid or be careful
- Using
latest, running as root, copying local credentials into an image, or mounting a writable data directory with assumptions about host permissions makes a reproducible Compose run fail in CI. - Do not conflate Compose with Docker. The second concept contributes different behavior: A declarative local orchestrator for multiple containers, their networks, health checks, and development volumes.
- Release only after this guardrail is in place: Pin image digests or versions, use multi-stage minimal images, run a non-root UID, declare health checks and dependencies, and inject secrets at runtime rather than baking them into layers.
Docker / Compose / Reproducibility - roles, limits, and operating cost
Strengths: An immutable layered executable artifact built from a Dockerfile for a consistent pipeline runtime. A Docker image packages a pinned runtime and pipeline dependencies, while Compose declares a local multi-service topology-database, object store, broker, and worker-with networks and volumes.
Watch out: Using latest, running as root, copying local credentials into an image, or mounting a writable data directory with assumptions about host permissions makes a reproducible Compose run fail in CI.
Strengths: A declarative local orchestrator for multiple containers, their networks, health checks, and development volumes. In this workflow it supports: Start - health-gated dependencies and one command per service.
Watch out: The operating cost is real: dependency is accepting traffic, not just started.
Strengths: The ability to create equivalent runtime behavior from committed source and pinned inputs on another machine. Its output can be checked with UID.
Watch out: Operating guardrail: Pin image digests or versions, use multi-stage minimal images, run a non-root UID, declare health checks and dependencies, and inject secrets at runtime rather than baking them into layers.
Interview signals & numbers to know
When this topic comes up
- “Where is the failure boundary for Docker, and how would Image tag reveal it?”
- “Why is Compose distinct from this behavior: the ability to create equivalent runtime behavior from committed source and pinned inputs on another machine?”
- Production clue: Using latest, running as root, copying local credentials into an image, or mounting a writable data directory with assumptions about host permissions makes a reproducible Compose run fail in CI.
- Design probe: Pin image digests or versions, use multi-stage minimal images, run a non-root UID, declare health checks and dependencies, and inject secrets at runtime rather than baking them into layers.
Benchmarks & rules of thumb
- Image tag
- immutable Git SHA or signed digest
- Health status
- dependency is accepting traffic, not just started
- UID
- non-root application user owns only needed writable paths
Common mistakes & follow-ups
Common interview mistakes
- Using
latest, running as root, copying local credentials into an image, or mounting a writable data directory with assumptions about host permissions makes a reproducible Compose run fail in CI. - Reporting success from a job exit code without checking Image tag and Health status.
- Treating this example as complete without replay, rollback, or access boundaries: A Compose service
ingesterwaits on Postgres'spg_isreadyhealth check, readsDATABASE_URL_FILE, mounts./outputexplicitly, and uses an immutableetl:git-shaimage built in CI.
Likely interviewer follow-ups
- How would you prove this contract instead of only checking that the command ran: An immutable layered executable artifact built from a Dockerfile for a consistent pipeline runtime.
- What does the recovery plan do when this occurs? Using
latest, running as root, copying local credentials into an image, or mounting a writable data directory with assumptions about host permissions makes a reproducible Compose run fail in CI. - When is Docker insufficient for Health status, and what does adding Compose cost in Image tag?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Containerizing Data Pipelines with Docker & Docker Compose with data engineer interview Q&A and hands-on practice.