{"id":1800,"library":"apache-airflow-providers-docker","title":"Apache Airflow Docker Provider","description":"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.","status":"active","version":"4.5.4","language":"en","source_language":"en","source_url":"https://github.com/apache/airflow/tree/main/airflow/providers/docker","tags":["airflow","docker","provider","orchestration","etl"],"install":[{"cmd":"pip install apache-airflow-providers-docker","lang":"bash","label":"Install the Docker Provider"}],"dependencies":[{"reason":"This is an Airflow provider; it requires a compatible Apache Airflow installation. For provider version 4.5.4, Airflow >=2.11.0 is required.","package":"apache-airflow","optional":false},{"reason":"The provider uses the Python Docker SDK to interact with the Docker daemon. Version >=5.0.3 is typically required.","package":"docker","optional":false}],"imports":[{"note":"Prior to Airflow 2.0 and the provider separation, operators were imported directly from `airflow.operators`. Always use the provider-specific path for `DockerOperator`.","wrong":"from airflow.operators.docker import DockerOperator","symbol":"DockerOperator","correct":"from airflow.providers.docker.operators.docker import DockerOperator"}],"quickstart":{"code":"import os\nfrom datetime import datetime\n\nfrom airflow.models.dag import DAG\nfrom airflow.providers.docker.operators.docker import DockerOperator\n\nwith DAG(\n    dag_id='docker_operator_quickstart',\n    start_date=datetime(2023, 1, 1),\n    schedule_interval=None,\n    catchup=False,\n    tags=['docker', 'example'],\n) as dag:\n    run_docker_task = DockerOperator(\n        task_id='run_hello_world_in_docker',\n        image='python:3.10-slim-buster',\n        command='python -c \"print(\\'Hello from Docker container in Airflow!\\')\"',\n        auto_remove='force', # Automatically remove the container on exit\n        mount_tmp_dir=False, # Set to True or False depending on local/remote Docker setup\n        docker_url=os.environ.get('DOCKER_HOST', 'unix://var/run/docker.sock'), # Use DOCKER_HOST env var or default\n    )","lang":"python","description":"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."},"warnings":[{"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.","message":"Provider 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.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Replace `volumes` with `mounts` in `DockerOperator` configurations. Refer to the official documentation for the `mounts` parameter syntax.","message":"For 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.","severity":"breaking","affected_versions":">=2.0.0"},{"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.","message":"Each `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.","severity":"breaking","affected_versions":"All versions"},{"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.","message":"When 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Provider 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.","severity":"breaking","affected_versions":">=4.4.1"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}