我已经使用 docker-compose 安装了 airflow 2.0.2,如 https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html 中所述.
我已经研究了很长时间,但我没有找到为我的 DAG 安装 python 依赖项的方法。我知道如何使用 Dockerfile (COPY requirements.txt/app
/RUN pip install -r requirements.txt
) 执行此操作,但此处不涉及 Dockerfile。
- 如何在 airflow 2.0.2/docker-compose 中安装 python 依赖项?
- 我需要在使用自定义 docker-compose 部署的六个容器中的哪个上安装依赖项?
最佳答案
而不是使用
image: apache/airflow:x.x.x
在你的 docker compose 中,你想将其设置为
build:
context: .
dockerfile: Dockerfile
然后将其写入您的 Dockerfile
FROM apache/airflow:x.x.x
COPY requirements.txt ./requirements.txt
您的 requirements.txt 包含 python 包。所以你没有使用图像,而是通过安装 python 包再次构建它。
关于python - Airflow 2/docker-compose : how to install Python dependencies for DAGs?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67486845/