以下是一个示例Docker Compose文件,用于启动Airflow服务:
version: '3'
services:
postgres:
image: postgres:10
restart: always
environment:
POSTGRES_USER: airflow
POSTGRES_PASSWORD: airflow
POSTGRES_DB: airflow
webserver:
image: apache/airflow:2.0.1
depends_on:
- postgres
ports:
- "8080:8080"
environment:
- AIRFLOW__CORE__EXECUTOR=LocalExecutor
- AIRFLOW__CORE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@postgres:5432/airflow
volumes:
- ./dags:/opt/airflow/dags
- ./logs:/opt/airflow/logs
- ./plugins:/opt/airflow/plugins
scheduler:
image: apache/airflow:2.0.1
depends_on:
- postgres
- webserver
environment:
- AIRFLOW__CORE__EXECUTOR=LocalExecutor
- AIRFLOW__CORE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@postgres:5432/airflow
volumes:
- ./dags:/opt/airflow/dags
- ./logs:/opt/airflow/logs
- ./plugins:/opt/airflow/plugins
这个Docker Compose文件定义了三个服务:postgres、webserver和scheduler。其中postgres用于作为Airflow的后端元数据库,webserver服务用于启动Airflow Web界面和运行DAG文件,scheduler用于调度任务和执行DAG。由于webserver和scheduler都需要postgres服务,因此在它们的依赖项中都列出了postgres。
通过运行docker-compose up
命令,这些服务将随后在Docker中自动启动。
上一篇:ApacheAirflow无法执行任何DAG-为什么?
下一篇:apacheairflow中BeamRunPythonPipelineOperator与DataFlowPythonOperator的区别是什么?