Registry / devops / apache-airflow-providers-docker

apache-airflow-providers-docker

JSON →
library4.5.9pypypi✓ verified 25d ago

The Apache Airflow Docker Provider package enables Airflow to interact with Docker, allowing users to execute tasks within Docker containers. This provider is actively maintained and frequently updated, with the current version being 4.5.4. All core functionalities are encapsulated within the `airflow.providers.docker` Python package.

pip install apache-airflow-providers-docker
INSTALL
IMPORT
SIG · APACHE-AIRFLOW-PRO
A
apache-airflow-providers-docker
devopspythonv4.5.9
Install
24.2s avg
Import
5696ms
Disk
258MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.5.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 5.890s · 258.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 24.2s · import 5.502s · 257MB
258MB installed
● package 258MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DockerOperator
from airflow.providers.docker.operators.docker import DockerOperator
from airflow.operators.docker import DockerOperator
Prior to Airflow 2.0 and the provider separation, operators were imported directly from `airflow.operators`. Always use the provider-specific path for `DockerOperator`.

This quickstart demonstrates a basic Airflow DAG using the `DockerOperator` to execute a simple Python command within a Docker container. It uses environment variables for Docker host URL and explicitly handles container removal and temporary directory mounting, common considerations for Docker environments.

import os from datetime import datetime from airflow.models.dag import DAG from airflow.providers.docker.operators.docker import DockerOperator with DAG( dag_id='docker_operator_quickstart', start_date=datetime(2023, 1, 1), schedule_interval=None, catchup=False, tags=['docker', 'example'], ) as dag: run_docker_task = DockerOperator( task_id='run_hello_world_in_docker', image='python:3.10-slim-buster', command='python -c "print(\'Hello from Docker container in Airflow!\')"', auto_remove='force', # Automatically remove the container on exit mount_tmp_dir=False, # Set to True or False depending on local/remote Docker setup docker_url=os.environ.get('DOCKER_HOST', 'unix://var/run/docker.sock'), # Use DOCKER_HOST env var or default )
airflow --version
Debug
Known issues
breakingProvider version 3.0.0 removed the `xcom_push` parameter from the `DockerOperator`. Functionality for XCom pushing might need to be implemented differently or rely on standard stdout capture.
fix
Review your `DockerOperator` usage; `xcom_push` is no longer supported directly. Consider using `do_xcom_push` (if applicable for task type) or explicitly handling XCom output in your container's command.
affects: >=3.0.0
breakingFor provider versions around 2.0.0 and newer, the `volumes` parameter in `DockerOperator` was replaced by the `mounts` parameter. This change requires updating how volumes are specified to align with the newer mount syntax.
fix
Replace `volumes` with `mounts` in `DockerOperator` configurations. Refer to the official documentation for the `mounts` parameter syntax.
affects: >=2.0.0
breakingEach `apache-airflow-providers-docker` version requires a specific minimum version of `apache-airflow`. For example, provider 3.0.0 requires Airflow >=2.2.0, while 4.5.4 requires Airflow >=2.11.0. Installing a mismatched provider version can lead to automatic Airflow upgrades or import errors.
fix
Always check the `apache-airflow` dependency specified in the provider's `requirements` or changelog for the installed version. Ensure your Airflow environment meets the minimum version before installing or upgrading the provider.
affects: All versions
gotchaWhen using `DockerOperator` with a remote Docker Engine or in a Docker-in-Docker setup, you might encounter issues or warnings related to temporary directory mounting. Setting `mount_tmp_dir=False` might be necessary to ensure smooth operation.
fix
If running in a remote Docker or Docker-in-Docker environment, explicitly set `mount_tmp_dir=False` in your `DockerOperator` configuration to prevent unexpected behavior.
affects: All versions
breakingProvider version 4.4.1 dropped support for Python 3.9. Users on older Python versions will need to upgrade their Python environment. The current version requires Python >=3.10.
fix
Ensure your Python environment is version 3.10 or newer. Upgrade Python if you are using an older version and wish to use `apache-airflow-providers-docker` >=4.4.1.
affects: >=4.4.1
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'airflow.providers.docker'
The 'apache-airflow-providers-docker' package is not installed in the Airflow environment.
fix
Install the package using pip: 'pip install apache-airflow-providers-docker'.
ImportError: cannot import name 'DockerOperator' from 'airflow.providers.docker.operators.docker'
The 'DockerOperator' class has been moved or renamed in the 'apache-airflow-providers-docker' package.
fix
Update the import statement to: 'from airflow.providers.docker.operators.docker import DockerOperator'.
ValueError: Invalid 'auto_remove' value 'always', expected one of 'never', 'success', or 'force'.
An invalid value was provided for the 'auto_remove' parameter in the 'DockerOperator'.
fix
Set the 'auto_remove' parameter to one of the valid values: 'never', 'success', or 'force'.
DockerContainerFailedException: Docker container failed with exit code 1.
The Docker container executed by the 'DockerOperator' exited with a non-zero status, indicating an error.
fix
Check the container logs to diagnose the issue and ensure the command and environment are correctly configured.
AttributeError: module 'airflow.providers.docker' has no attribute 'DockerOperator'
The 'DockerOperator' is not directly accessible from 'airflow.providers.docker'.
fix
Import 'DockerOperator' from the correct module: 'from airflow.providers.docker.operators.docker import DockerOperator'.
Upgrade
Version history
4.5.9latest on PyPI · released Aug 8, 2026
Audit
Dependencies
apache-airflowrequiredThis is an Airflow provider; it requires a compatible Apache Airflow installation. For provider version 4.5.4, Airflow >=2.11.0 is required.
dockerrequiredThe provider uses the Python Docker SDK to interact with the Docker daemon. Version >=5.0.3 is typically required.
Agent activity
54 hits · last 30 days
node
50
OpenAI (training)
1
Resources
apache-airflow-providers-docker — pip install apache-airflow-providers-docker · libregistry