Skip to content
Advertisement

How to install packages in Airflow (docker-compose)?

The question is very similar to the one already available. The only difference is that I ran Airflow in docker

Step by step:

  1. Put docker-compose.yaml to PyCharm project
  2. Put requirements.txt to PyCharm project
  3. Run docker-compose up
  4. Run DAG and receive a ModuleNotFoundError

I want to start Airflow using docker-compose with the dependencies from requirements.txt. These dependencies should be available by PyCharm interpreter and during DAGs execution

Is there a solution that doesn’t require rebuilding the image?

Advertisement

Answer

Is there a solution that doesn’t require rebuilding the image?

Yes there is now: currently (oct-2021 v2.2.0) it’s available as an env variable:

_PIP_ADDITIONAL_REQUIREMENTS

It is used in the docker-compose.yml file. That should do the trick without building a complete image as some of the other answers explain (very well actually :-)

See: https://airflow.apache.org/docs/apache-airflow/stable/docker-compose.yaml

Official documentation https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html#environment-variables-supported-by-docker-compose

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement