Principle:Apache Airflow Docker Image Preparation
| Knowledge Sources | |
|---|---|
| Domains | Containerization, DevOps |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
A multi-stage Docker build process for creating production-ready Airflow container images with configurable extras and entrypoint scripts.
Description
Docker Image Preparation defines how Airflow is packaged into container images suitable for Kubernetes deployment. The build uses a multi-stage Dockerfile: a build stage compiles native dependencies and a runtime stage produces a minimal production image. The production entrypoint script handles connection retries, LD_PRELOAD workarounds, and init script execution. Custom images can extend the base with additional Python packages, system dependencies, or DAG files baked in.
Usage
Use this principle when building custom Airflow Docker images for Kubernetes deployment. Extend the official image with additional providers, custom dependencies, or embedded DAGs for air-gapped environments.
Theoretical Basis
Multi-stage Build Pattern:
- Build Stage (airflow-build-image): Compiles native extensions, installs build tools
- Runtime Stage (main): Copies compiled artifacts, minimal OS packages
- Benefits: Smaller final image, no build tools in production
Entrypoint Initialization:
- Wait for database connection (retry loop)
- Apply LD_PRELOAD workaround if configured
- Execute custom init scripts from /opt/airflow/init/
- Run the requested Airflow command