gpt4 book ai didi

docker - 如何访问 Airflow 2.0 cli

转载 作者:行者123 更新时间:2023-12-05 09:04:00 24 4
gpt4 key购买 nike

我正在使用 docker 运行 Airflow ,我想使用 cli 执行 pauseunpause dag,因为我无法在远程安装浏览器Digital Ocean droplet 服务器,用于访问 airflow UI。

目前我正在尝试使用命令访问 airflow cli sudo docker exec -it $(docker-compose -f docker-compose.yaml ps -q webserver) bash但是我收到一个错误

docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied'))[95826] Failed to execute script docker-compose"docker exec" requires at least 2 arguments.

下面是我的docker-compose.yaml文件

version: '3'
x-airflow-common:
&airflow-common
image: ${AIRFLOW_IMAGE_NAME:-apache/airflow:2.0.1}
environment:
&airflow-common-env
AIRFLOW__CORE__EXECUTOR: LocalExecutor
AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres/airflow
AIRFLOW__CORE__FERNET_KEY: ''
AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: 'true'
AIRFLOW__CORE__LOAD_EXAMPLES: 'false'
volumes:
- ./dags:/opt/airflow/dags
- ./logs:/opt/airflow/logs
- ./plugins:/opt/airflow/plugins
user: "${AIRFLOW_UID:-50000}:${AIRFLOW_GID:-50000}"
depends_on:
postgres:
condition: service_healthy

services:
postgres:
image: postgres:13
environment:
POSTGRES_USER: airflow
POSTGRES_PASSWORD: airflow
POSTGRES_DB: airflow
volumes:
- postgres-db-volume:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-U", "airflow"]
interval: 5s
retries: 5
restart: always

airflow-webserver:
<<: *airflow-common
command: webserver
ports:
- 8081:8080
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:8080/health"]
interval: 10s
timeout: 10s
retries: 5
restart: always

airflow-scheduler:
<<: *airflow-common
command: scheduler
restart: always

airflow-init:
<<: *airflow-common
command: version
environment:
<<: *airflow-common-env
_AIRFLOW_DB_UPGRADE: 'true'
_AIRFLOW_WWW_USER_CREATE: 'true'
_AIRFLOW_WWW_USER_USERNAME: ${_AIRFLOW_WWW_USER_USERNAME:-airflow}
_AIRFLOW_WWW_USER_PASSWORD: ${_AIRFLOW_WWW_USER_PASSWORD:-airflow}

volumes:
postgres-db-volume:

我该如何解决这个问题?

最佳答案

如果您查看我们最近的 quick-start docker compose,你会看到你可以添加一个单独的 `airflow-cli' docker compose(它将在明天/后天与 2.1.4 一起发布,但你可以在这里看到它:

https://github.com/apache/airflow/blob/v2-1-stable/docs/apache-airflow/start/docker-compose.yaml#L229

  airflow-cli:
<<: *airflow-common
profiles:
- debug
environment:
<<: *airflow-common-env
CONNECTION_CHECK_MAX_COUNT: "0"
# Workaround for entrypoint issue. See: https://github.com/apache/airflow/issues/16252
command:
- bash
- -c
- airflow

如果您将此添加到您的 docker-compose,您可以运行 docker-compose run airflow-cli <command> (和其他命令)

debug配置文件确保 airflow-cli默认情况下不启动服务,仅当您指定 --profile debug 时才启动或明确指定要运行的服务。

关于docker - 如何访问 Airflow 2.0 cli,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69163022/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com