Implementation:Apache Airflow Dockerfile Build
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Containerization, DevOps |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Concrete tool for building production Airflow Docker images using the multi-stage Dockerfile and entrypoint scripts.
Description
The Dockerfile uses BuildKit v1.4 syntax with multi-stage builds. The entrypoint_prod.sh script handles production container startup including database connection waiting and init script execution. The entrypoint_exec.sh script handles the exec form for running Airflow commands.
Usage
Build custom Airflow images by extending the official Dockerfile or using docker build with custom build arguments.
Code Reference
Source Location
- Repository: Apache Airflow
- File: Dockerfile (multi-stage build)
- File: scripts/docker/entrypoint_prod.sh (production entrypoint)
- File: scripts/docker/entrypoint_exec.sh (exec entrypoint)
Signature
# Key build arguments
ARG AIRFLOW_VERSION="3.1.7"
ARG AIRFLOW_UID=50000
ARG AIRFLOW_HOME=/opt/airflow
ARG AIRFLOW_EXTRAS="cncf-kubernetes,celery,docker,..."
ARG PYTHON_BASE_IMAGE="python:3.x-slim"
# Multi-stage build:
# Stage 1: airflow-build-image (compilation)
# Stage 2: main (runtime)
Import
# Build the image
docker build -t my-airflow:latest .
# Or extend the official image
FROM apache/airflow:3.1.7
RUN pip install my-custom-package
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| AIRFLOW_VERSION | Build arg | No | Airflow version (default 3.1.7) |
| AIRFLOW_UID | Build arg | No | User ID in container (default 50000) |
| AIRFLOW_EXTRAS | Build arg | No | Comma-separated pip extras to install |
| PYTHON_BASE_IMAGE | Build arg | No | Base Python image |
Outputs
| Name | Type | Description |
|---|---|---|
| Docker image | Container image | Production-ready Airflow image |
| Entrypoint | Shell script | Handles startup, connection retry, init scripts |
Usage Examples
Build Custom Image
# Build with default settings
docker build -t my-airflow:latest .
# Build with specific extras
docker build --build-arg AIRFLOW_EXTRAS="cncf-kubernetes,celery,amazon" -t my-airflow:latest .
# Extend official image
cat > Dockerfile.custom << 'EOF'
FROM apache/airflow:3.1.7
USER root
RUN apt-get update && apt-get install -y gcc
USER airflow
RUN pip install my-custom-package
EOF
docker build -f Dockerfile.custom -t my-airflow:custom .
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment