2024-05-13 02:34:39 发布
网友
这个问题与the one already available非常相似。唯一的区别是我在docker中运行气流
逐步:
requirements.txt
docker-compose up
ModuleNotFoundError
我想从requirements.txt的依赖项开始using docker-compose。PyCharm解释器应在DAG执行期间提供这些依赖项
是否有不需要重建图像的解决方案
在讨论中得到the answer。现在唯一的方法是安装额外的python包来构建自己的映像。我将尝试更详细地解释这个解决方案
步骤1。将Dockerfile、docker-compose.yaml和requirements.txt文件放入项目目录
Dockerfile
docker-compose.yaml
步骤2。粘贴到以下文件代码:
FROM apache/airflow:2.1.0 COPY requirements.txt . RUN pip install -r requirements.txt
步骤3。粘贴到docker-compose.yaml代码,您可以找到in the official documentation。将第image: ${AIRFLOW_IMAGE_NAME:-apache/airflow:2.1.0}节替换为build: .:
image: ${AIRFLOW_IMAGE_NAME:-apache/airflow:2.1.0}
build: .
- version: '3' x-airflow-common: &airflow-common build: . # REPLACED # image: ${AIRFLOW_IMAGE_NAME:-apache/airflow:2.1.0} environment: &airflow-common-env AIRFLOW__CORE__EXECUTOR: CeleryExecutor AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres/airflow AIRFLOW__CELERY__RESULT_BACKEND: db+postgresql://airflow:airflow@postgres/airflow AIRFLOW__CELERY__BROKER_URL: redis://:@redis:6379/0 AIRFLOW__CORE__FERNET_KEY: '' AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: 'true' AIRFLOW__CORE__LOAD_EXAMPLES: 'false' AIRFLOW__API__AUTH_BACKEND: 'airflow.api.auth.backend.basic_auth' volumes: - ./dags:/opt/airflow/dags - ./logs:/opt/airflow/logs - ./plugins:/opt/airflow/plugins user: "${AIRFLOW_UID:-50000}:${AIRFLOW_GID:-50000}" depends_on: redis: condition: service_healthy postgres: condition: service_healthy # ...
此时您的项目目录应如下所示:
airflow-project |docker-compose.yaml |Dockerfile |requirements.txt
第4步。运行docker-compose up启动气流,docker-compose应该从Dockerfile自动构建图像。运行docker-compose build重建映像并更新依赖项
docker-compose
docker-compose build
Is there a solution that doesn't require rebuilding the image?
是的,现在有:目前(2021年10月v2.2.0)它作为一个环境变量提供:
_PIP_ADDITIONAL_REQUIREMENTS
它在docker-compose.yml文件中使用。 正如其他一些答案所解释的那样,这应该可以在不建立完整形象的情况下实现(实际上非常好:-)
见:https://airflow.apache.org/docs/apache-airflow/stable/docker-compose.yaml
官方文件https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html#environment-variables-supported-by-docker-compose
另一种方法是更新文件docker-compose.yml,将下面的行与所需的所有命令放在一起
command: -c "pip3 install apache-airflow-providers-sftp apache-airflow-providers-ssh user"
并重建图像
docker-compose up airflow-init docker-compose up
在讨论中得到the answer。现在唯一的方法是安装额外的python包来构建自己的映像。我将尝试更详细地解释这个解决方案
步骤1。将
Dockerfile
、docker-compose.yaml
和requirements.txt
文件放入项目目录步骤2。粘贴到以下文件代码:
步骤3。粘贴到
docker-compose.yaml
代码,您可以找到in the official documentation。将第image: ${AIRFLOW_IMAGE_NAME:-apache/airflow:2.1.0}
节替换为build: .
:此时您的项目目录应如下所示:
第4步。运行
docker-compose up
启动气流,docker-compose
应该从Dockerfile
自动构建图像。运行docker-compose build
重建映像并更新依赖项是的,现在有:目前(2021年10月v2.2.0)它作为一个环境变量提供:
它在docker-compose.yml文件中使用。 正如其他一些答案所解释的那样,这应该可以在不建立完整形象的情况下实现(实际上非常好:-)
见:https://airflow.apache.org/docs/apache-airflow/stable/docker-compose.yaml
官方文件https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html#environment-variables-supported-by-docker-compose
另一种方法是更新文件docker-compose.yml,将下面的行与所需的所有命令放在一起
并重建图像
相关问题 更多 >
编程相关推荐