https://prefect.io logo
Title
n

Nimesh Kumar

03/10/2023, 5:45 PM
Hi i am trying to set up prefect using docker but not able to make connection with the /api and getting this message
Can't connect to Orion API at <http://0.0.0.0:4200/api>. 
Check that it's accessible from your machine.
This is my docker-compose which i am using to create the required prefect services.
version: "3.9"
services:

  database:
    image: postgres:15.2-alpine
    container_name: database
    restart: always
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=orion
    expose:
      - 5432
    volumes: 
      - db:/var/lib/postgresql/data
    networks:
      - backend
     
  minio:
    image: minio/minio:latest
    container_name: minio
    entrypoint: ["minio", "server", "--address", "0.0.0.0:9000", "--console-address", "0.0.0.0:9001", "/data"]
    volumes:
      - "minio:/data"
    ports:
      - 9000:9000
      - 9001:9001
    networks:
      - backend
     
  orion:
    image: prefecthq/prefect:2.8.2-python3.11
    container_name: orion
    restart: always
    volumes:
      - prefect:/root/.prefect
    entrypoint: ["prefect", "orion", "start"]
    working_dir: "/root/flows"
    volumes:
      - "./flows:/root/flows"
      - "./flows/tmp:/tmp"
      - "./flows/tmp_folder:/tmp_folder"
    working_dir: "/root/flows"
    environment:
      - PREFECT_UI_URL=<http://127.0.0.1:4200/api>
      - PREFECT_ORION_API_HOST=0.0.0.0
      - PREFECT_ORION_DATABASE_CONNECTION_URL=<postgresql+asyncpg://postgres:postgres@database:5432/orion>
    ports:
      - 4200:4200
    depends_on:
      - database
    networks:
      - backend
 
  agent:
    image: prefecthq/prefect:2.8.2-python3.11
    container_name: agent
    restart: always
    entrypoint: ["prefect", "agent", "start", "-q", "queue_1", "-q", "queue_2", "-q", "queue_3"]
    volumes:
      - "./flows:/root/flows"
      - "./flows/tmp:/tmp"
      - "./flows/tmp_folder:/tmp_folder"
    environment:
      - PREFECT_API_URL=<http://127.0.0.1:4200/api>
    networks:
      - backend
    
volumes:
  prefect:
  db:
  minio:
networks:
  backend:
    driver: "bridge"
Can anyone please check where i am doing wrong ... Thanks
d

David Steiner Sand

03/10/2023, 6:16 PM
By referencing
<http://127.0.0.1:4200/api>
in the agent you are actually referencing the local IP of the agent container, where no prefect server is running. What you can do is take advantage of the docker-compose networking and reference instead
<http://orion:4200/api>
, see https://docs.docker.com/compose/networking/
n

Nimesh Kumar

03/10/2023, 7:39 PM
Tried that too. but still the same error. This docker compose i am running in WSL, so i tried wsl IP also, but still the error is same