简体   繁体   English

无法在 Airflow 1.10.14 上运行 DAG,在官方 Apache\Airflow 图像上运行 docker-compose

[英]Fail to run DAG on Airflow 1.10.14 running with docker-compose on official Apache\Airflow image

I've been trying to set Airflow 1.10.14 to execute Python based process, on docker container using docker-compose. The host is Ubuntu 18 VM.我一直在尝试设置 Airflow 1.10.14 以使用 docker-compose 在 docker 容器上执行基于 Python 的进程。主机是 Ubuntu 18 VM。

My Dockerfile:我的 Dockerfile:

FROM apache/airflow:1.10.14
USER root
RUN pip install --upgrade pip
RUN pip install --user psycopg2-binary

COPY airflow.cfg /opt/airflow/

RUN apt-get update && apt-get install -y \
    libodbc1 \
    python3-dev\
    libevent-dev\
    unixodbc-dev \
    freetds-dev \
    freetds-bin -y \ 
    tdsodbc -y \
    build-essential

# install dependencies
ADD requirements.txt .
RUN pip install -r requirements.txt


USER airflow

Then I execute:然后我执行:

docker build -t learning/airflow .

And my docker-compose.yml is:而我的 docker-compose.yml 是:

version: "3"
networks:
  airflow:

services:
  postgres:
    image: "postgres:9.6"
    container_name: "postgres"
    environment:
      - POSTGRES_USER=airflow
      - POSTGRES_PASSWORD=airflow
      - POSTGRES_DB=airflow
    ports:
      - "5432:5432"
    networks:
      - airflow

  # uncomment initdb if you need initdb at first run
  initdb:
    image: learning/airflow
    entrypoint: airflow db init
    depends_on:
      - postgres
    networks:
      - airflow

  webserver:
    image: learning/airflow
    restart: always
    depends_on:
      - postgres
    volumes:
      - ./dags:/opt/airflow/dags
    ports:
      - "8080:8080"
    entrypoint: airflow webserver
    healthcheck:
      test: ["CMD-SHELL", "[ -f /opt/airflow/airflow-webserver.pid ]"]
      interval: 30s
      timeout: 30s
      retries: 3
    networks:
      - airflow

  scheduler:
    image: learning/airflow
    restart: always
    depends_on:
      - postgres
      - webserver
    volumes:
      - ./dags:/opt/airflow/dags
      - ./logs:/opt/airflow/logs
    entrypoint: airflow scheduler
    healthcheck:
      test: ["CMD-SHELL", "[ -f /opt/airflow/airflow-scheduler.pid ]"]
      interval: 30s
      timeout: 30s
      retries: 3
    networks:
      - airflow

I also use the airflow.cfg as appear in here (with minor changes) In the first run I execute in 3 steps in separated terminals:我还使用此处显示的 airflow.cfg(稍作更改)在第一次运行中,我在单独的终端中分 3 个步骤执行:

docker-compose up postgres
docker-compose up initdb
docker-compose up webserver scheduler

I'm able to access the Airflow UI and turn on the DAG but first step fails immediately with the following error:我能够访问 Airflow 用户界面并打开 DAG,但第一步立即失败并出现以下错误:

*** Log file does not exist: /opt/airflow/logs/stg_process/Process_g/2020-12-23T00:00:00+00:00/2.log
*** Fetching from: http://bf23abdeb4b0:8793/log/stg_process/Process_g/2020-12-23T00:00:00+00:00/2.log
*** Failed to fetch log file from worker. HTTPConnectionPool(host='bf23abdeb4b0', port=8793): Max retries
exceeded with url:
/log/stg_process/Process_g/2020-12-23T00:00:00+00:00/2.log
(Caused by NewConnectionError('<urllib3.connection.HTTPConnection
object at 0x7ff6f20ae898>: Failed to establish a new connection:
[Errno 111] Connection refused',))

What am I missing here?我在这里错过了什么? any help will be appreciated...任何帮助将不胜感激...

Try resetting the metadata db and then build again?尝试重置元数据数据库然后重新构建?

airflow resetdb

I may be late, but I think the problem is on this line on your Dockerfile:我可能迟到了,但我认为问题出在您 Dockerfile 的这一行上:

COPY airflow.cfg /opt/airflow/

Should be like this:应该是这样的:

COPY airflow.cfg /opt/airflow/airflow.cfg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在官方 Airflow docker-compose 上运行 airflow 命令 - Run airflow commands on official Airflow docker-compose 如何为使用官方 docker-compose 运行的 Airflow 设置远程调试? - How to setup remote debug for Airflow running with official docker-compose? 使用docker-compose运行分布式气流架构时如何将新用户添加到docker镜像 - How to add new user to docker image when running distributed airflow architecture using docker-compose 从不同的文件夹运行 Airflow 和 docker-compose - Run Airflow with docker-compose from a different folder 在 docker-compose 上运行的气流中显示管理员配置 - Show admin configuration in airflow running on docker-compose 如何使用官方 docker-compose 文件安装 Airflow 的附加要求 - How to install additional requirements for Airflow using official docker-compose file Airflow 网络服务器无法识别 docker-compose 中的 Airflow 调度程序 - Airflow webserver can't recognize Airflow Scheduler in docker-compose 如何在 Airflow (docker-compose) 中安装包? - How to install packages in Airflow (docker-compose)? Apache Airflow 配置文件:docker-compose 文件中的环境变量不起作用 - Apache Airflow configuration files: Environment variables in docker-compose file doesn't work 在 docker-compose 上为 Airflow 启用实时重新加载很热? - Hot to enable live reload on docker-compose for Airflow?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM