> For the complete documentation index, see [llms.txt](https://til.duyet.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.duyet.net/data-engineering/apache-airflow/airflow-in-docker-compose.md).

# Airflow in Docker Compose

```yaml
# docker-compose.env

POSTGRES_USER=airflow
POSTGRES_PASSWORD=airflow
POSTGRES_DB=airflow
LOAD_EX=n
EXECUTOR=Local
AIRFLOW__CORE__DAGS_FOLDER=/opt/airflow/dags
AIRFLOW__CORE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@postgres:5432/airflow
AIRFLOW__CORE__FERNET_KEY=.............
```

```yaml
# docker-compose.yml

version: '2.1'

services:
    postgres:
        image: postgres:9.6
        env_file:
            - docker-compose.env
        volumes:
            - /tmp/postgres-data:/var/lib/postgresql/data

    adminer:
        image: adminer
        restart: always
        ports:
        - 9999:8080

    webserver:
        build: .
        restart: always
        depends_on:
            - postgres
        env_file:
            - docker-compose.env
        volumes:
            - ./dags:/opt/airflow/dags
            - /tmp/airflow_logs:/root/airflow/logs
        ports:
            - "8080:8080"
        command: webserver
        healthcheck:
            test: ["CMD-SHELL", "[ -f /usr/local/airflow/airflow-webserver.pid ]"]
            interval: 30s
            timeout: 30s
            retries: 3

    scheduler:
        build: .
        restart: always
        depends_on:
            - postgres
        env_file:
            - docker-compose.env
        volumes:
            - ./dags:/opt/airflow/dags
            - /tmp/airflow_logs:/root/airflow/logs
        command: scheduler
```

```ocaml
# Dockerfile

FROM duyetdev/airflow:1.10.5

ENV PYTHONPATH "/opt/airflow/dags:$PYTHONPATH"
ENV AIRFLOW_HOME "/root/airflow"

COPY . /opt/airflow
RUN pip install -r /opt/airflow/requirements.txt

# Scripts, code, ...
COPY script/auth /
COPY dags /opt/airflow/dags
```

Run:

```ocaml
docker-compose up
```

Visit: <http://localhost:8080>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://til.duyet.net/data-engineering/apache-airflow/airflow-in-docker-compose.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
