0

Basically, I want to build the docker-airflow:

I have the Dockerfile like:

FROM puckel/docker-airflow:1.10.6
COPY ./airflow_home/airflow.cfg /usr/local/airflow/airflow.cfg
...

I have the docker-compose.yml like:

version: "3.4"
services:
    postgres:
        image: "postgres:9.6"
        container_name: "postgres"
        environment:
            - POSTGRES_USER=airflow
            - POSTGRES_PASSWORD=airflow
            - POSTGRES_DB=airflow
        ports:
            - "5432:5432"
        volumes:
            - './data/postgres:/var/lib/postgresql/data'
    # comment initdb after you will have use it at first run
    # set the client and processed log types here
    initdb:
        build: .
        entrypoint: airflow initdb
        entrypoint:
            ['python3', '/usr/local/airflow/__init__.py', '-C', '$Client', '-T', '$Types']
        volumes:
            - './airflow_home/packages:/usr/local/airflow/packages'
        depends_on:
            - postgres

And there is no other airflow library in the requirements.txt.

I always got the error when I did the:

docker-compose up webserver

The error is:

sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "connection" does not exist
webserver_1  | LINE 2: FROM connection GROUP BY connection.conn_id

The "xxx" include log as well.

I originally thought the error would come from the different versions. But I make sure the version has been confirmed right. I used the airflow.cfg comes from the same version and modified the sql_connection with Postgres. The database in Postgres has also been created. Does anyone know how to fix that?

4
  • I'm unclear why do you need the initdb section? the puckel docker will run initdb on startup. Also, you didn't include the airflow part in the posted snippet . It seems like initdb didn't run properly, checkout the logs of the started airflow Commented Apr 30, 2020 at 8:54
  • cuz I need to initialize some parameters for the following processes. I used to test well. The postgres and initdb all run successfully. I will attach the logs soon Commented Apr 30, 2020 at 8:58
  • I'd let the airflow image run the initdb part. Most params to airflow can be configured using environment variables. Commented Apr 30, 2020 at 9:01
  • Thanks for your opinions. Maybe I will give it a go. But now I do not think the problem is on initdb. Commented Apr 30, 2020 at 9:05

1 Answer 1

0

I found the reason. Cuz I used two entrypoints in initdb part. It will overwrite the original init script inside the docker. When I delete the entrypoint:

['python3', '/usr/local/airflow/__init__.py', '-C', '$Client', '-T', '$Types']

It works now.

Sign up to request clarification or add additional context in comments.

1 Comment

I would recommend if you want to execute the command in docker. Better use CMD in Dockerfile. It saves a lot of time to fix the bug brought by the arguments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.