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-dockerVerified import paths — ran on the pinned version, not inferred.
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.
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.
Replace `volumes` with `mounts` in `DockerOperator` configurations. Refer to the official documentation for the `mounts` parameter syntax.
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.
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.
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.
Install the package using pip: 'pip install apache-airflow-providers-docker'.
Update the import statement to: 'from airflow.providers.docker.operators.docker import DockerOperator'.
Set the 'auto_remove' parameter to one of the valid values: 'never', 'success', or 'force'.
Check the container logs to diagnose the issue and ensure the command and environment are correctly configured.
Import 'DockerOperator' from the correct module: 'from airflow.providers.docker.operators.docker import DockerOperator'.