title: Docker compose file for airflow 2 ( version 2.0.0 )
body: <p>I am looking to write docker compose file to locally execute airflow in production similar environent.</p>
  <p>For older airflow v1.10.14, docker compose is working fine. But same docker compose is not working for latest stable version, airflow scheduler &amp; webservice is failing continuously. error message looks like unable to create audit tables.</p>
  <p><code>docker-compose.yaml</code>:</p>
  <pre class="lang-yaml prettyprint-override"><code> version: &quot;2.1&quot;
  services:
    postgres:
      image: postgres:12
      environment:
        - POSTGRES_USER=airflow
        - POSTGRES_PASSWORD=airflow
        - POSTGRES_DB=airflow
      ports:
        - &quot;5433:5432&quot;
  
    scheduler:
      image: apache/airflow:1.10.14
      restart: always
      depends_on:
        - postgres
        - webserver
      env_file:
        - .env
      ports:
        - &quot;8793:8793&quot;
      volumes:
        - ./dags:/opt/airflow/dags
        - ./airflow-logs:/opt/airflow/logs
        - ./plugins:/opt/airflow/plugins
      command: scheduler
      healthcheck:
        test: [&quot;CMD-SHELL&quot;, &quot;[ -f /usr/local/airflow/airflow-webserver.pid ]&quot;]
        interval: 30s
        timeout: 30s
        retries: 5
  
    webserver:
      image: apache/airflow:1.10.14
      hostname: webserver
      restart: always
      depends_on:
        - postgres
      env_file:
        - .env
      volumes:
        - ./dags:/opt/airflow/dags
        - ./scripts:/opt/airflow/scripts
        - ./airflow-logs:/opt/airflow/logs
        - ./plugins:/opt/airflow/plugins
      ports:
        - &quot;8080:8080&quot;
      entrypoint: ./scripts/airflow-entrypoint.sh
      healthcheck:
        test: [&quot;CMD-SHELL&quot;, &quot;[ -f /usr/local/airflow/airflow-webserver.pid ]&quot;]
        interval: 30s
        timeout: 30s
        retries: 5
  </code></pre>
  <p><code>.env</code>:</p>
  <pre class="lang-yaml prettyprint-override"><code>AIRFLOW__CORE__LOAD_DEFAULT_CONNECTIONS=False
  AIRFLOW__CORE__SQL_ALCHEMY_CONN=postgres+psycopg2://airflow:airflow@postgres:5432/airflow
  AIRFLOW__CORE__FERNET_KEY=81HqDtbqAywKSOumSha3BhWNOdQ26slT6K0YaZeZyPs=
  AIRFLOW_CONN_METADATA_DB=postgres+psycopg2://airflow:airflow@postgres:5432/airflow
  AIRFLOW_VAR__METADATA_DB_SCHEMA=airflow
  AIRFLOW__SCHEDULER__SCHEDULER_HEARTBEAT_SEC=10
  </code></pre>
  <p><code>./scripts/airflow-entrypoint.sh</code>:</p>
  <pre class="lang-sh prettyprint-override"><code>#!/usr/bin/env bash
  airflow upgradedb
  airflow webserver
  </code></pre>