# Docker Compose snippet for DockerOperator support in Airflow
#
# Add these additions to your existing Airflow docker-compose.yaml:
#
# 1. Add the Docker socket volume to x-airflow-common:
#
#   x-airflow-common:
#     &airflow-common
#     volumes:
#       - ${AIRFLOW_PROJ_DIR:-.}/dags:/opt/airflow/dags
#       - ${AIRFLOW_PROJ_DIR:-.}/logs:/opt/airflow/logs
#       - ${AIRFLOW_PROJ_DIR:-.}/config:/opt/airflow/config
#       - ${AIRFLOW_PROJ_DIR:-.}/plugins:/opt/airflow/plugins
#       # For DockerOperator:
#       - /var/run/docker.sock:/var/run/docker.sock
#
# 2. Add this service to the services section:

services:
  # TCP proxy for DockerOperator - allows Airflow to run Docker containers
  # Reference: https://stackoverflow.com/questions/75513450
  docker-proxy:
    image: alpine/socat
    command: "TCP4-LISTEN:2375,fork,reuseaddr UNIX-CONNECT:/var/run/docker.sock"
    ports:
      - "127.0.0.1:2376:2375"  # Only listen on localhost for security
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
