title: Airflow 2 / Docker: adding custom network in docker-compose.yml fails
body: <p>I have installed airflow 2.0.2 using docker-compose as described under <a href="https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html" rel="nofollow noreferrer">https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html</a>. The used docker-compose.yml can be found here: <a href="https://airflow.apache.org/docs/apache-airflow/2.0.2/docker-compose.yaml" rel="nofollow noreferrer">https://airflow.apache.org/docs/apache-airflow/2.0.2/docker-compose.yaml</a></p>
  <p>I want to execute a DAG which downloads some data via an API and sends it into a Kafka server which is running in yet another docker container (defined in another docker-compose pipeline). So far (without using airflow), I used a custom docker network for the kafka / zookeper containers; that's why I also want to add the airflow docker containers to this network.</p>
  <p>Thus, I add the following to the airflow's docker-compose.yml:</p>
  <pre><code>networks:
    app-tier:
      driver: bridge
      name: app-tier
  </code></pre>
  <p>Additionally, I include the <code>networks</code> argument to <code>x-airflow-common</code>, like so:</p>
  <pre><code>version: '3'
  x-airflow-common:
    &amp;airflow-common
    build: .
    image: ${AIRFLOW_IMAGE_NAME:-apache/airflow:2.0.2}
    environment:
      &amp;airflow-common-env
      AIRFLOW__CORE__EXECUTOR: CeleryExecutor
      AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres/airflow
      AIRFLOW__CELERY__RESULT_BACKEND: db+postgresql://airflow:airflow@postgres/airflow
      AIRFLOW__CELERY__BROKER_URL: redis://:@redis:6379/0
      AIRFLOW__CORE__FERNET_KEY: ''
      AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: 'false'
      AIRFLOW__CORE__LOAD_EXAMPLES: 'false'
      AIRFLOW__API__AUTH_BACKEND: 'airflow.api.auth.backend.basic_auth'
    volumes:
      - ./dags:/opt/airflow/dags
      - ./logs:/opt/airflow/logs
      - ./plugins:/opt/airflow/plugins
    user: &quot;${AIRFLOW_UID:-50000}:${AIRFLOW_GID:-50000}&quot;
    depends_on:
      redis:
        condition: service_healthy
      postgres:
        condition: service_healthy
    networks:
      - app-tier
  </code></pre>
  <p>However, when starting my docker-compose pipeline, the health checks of all containers excluding Postgres and Redis (worker, webserver, flower, scheduler) fail, with the following message:</p>
  <blockquote>
  <p>daniel@Yoga:~/Schreibtisch/Projekte/db/airflow_neu$ docker logs airflowWorker<br />
  BACKEND=postgresql+psycopg2 DB_HOST=postgres</p>
  <p>DB_PORT=5432 .................... ERROR! Maximum number of retries
  (20) reached.</p>
  <p>Last check result: $ run_nc 'postgres' '5432' Traceback (most recent
  call last):   File &quot;&quot;, line 1, in  socket.gaierror:
  [Errno -3] Temporary failure in name resolution Can't parse  as an IP
  address</p>
  </blockquote>
  <p>I interpret this as the Postgres database not being reachable anymore, but I don't know how to resolve this.</p>
  <ul>
  <li>Is my approach correct to add the airflow containers to an existing network?</li>
  <li>How can I resolve the failing health checks?</li>
  </ul>