Docker-socket-proxy / 503 Server error : Service unavailable

Hi,

I created a DockerOperator task in my DAG :

   t1 = DockerOperator(
        task_id='container_exec',
        image='xxxx:4:0.0.1',
        container_name='task_container_exec',
        api_version='auto',
        auto_remove=True,
        docker_url='tcp://docker-proxy:2375',
        network_mode='bridge',
        dag=dag
    )

This is an excerpt of my docker-compose.yml :

  docker-socket-proxy:
    image: tecnativa/docker-socket-proxy:0.1.1
    environment:
      CONTAINERS: 1
      IMAGES: 1
      AUTH: 1
      POST: 1
    privileged: true
    ports:
      - 127.0.0.1:2375:2375
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    restart: always

When the task is executed, I get this error message :

[2021-10-12 06:33:30,934] {taskinstance.py:1481} ERROR - Task failed with exception
Traceback (most recent call last):
  File "/home/airflow/.local/lib/python3.6/site-packages/docker/api/client.py", line 261, in _raise_for_status
    response.raise_for_status()
  File "/home/airflow/.local/lib/python3.6/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 503 Server Error: Service Unavailable for url: http://docker-proxy:2375/version

Any ideas for the cause of the problem ?

Thank you in advance

You’ll have to make sure your DockerOperator now points to the proxy by using the docker_url parameter and setting it to tcp://host.docker.internal:2375

    hello_world = DockerOperator(
        task_id="hello_world",
        image="hello-world:latest",
        docker_url="tcp://host.docker.internal:2375",
        network_mode="bridge",
        api_version="auto",
        auto_remove=True,
    )
1 Like