You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker容器中Prefect Server API无法连接问题求助

Docker部署Prefect Server本地无法连接容器服务问题

使用Docker容器部署Prefect Server(版本2.10.4,当前最新版)时,出现本地环境无法连接容器内服务的问题,搜索相关问题后未找到确切解决方案,若需更多信息可告知。

操作步骤

  • 使用如下docker-compose.yml配置文件:
version: "3.9"
services:
  ### PostgreSQL Database
  database:
    image: postgres:14.1-alpine
    restart: always
    environment:
      - POSTGRES_USER=prefect
      - POSTGRES_PASSWORD=prefect
      - POSTGRES_DB=prefect
    expose:
      - 5432
    volumes: 
      - postgres:/var/lib/postgresql/data
    profiles: ["server"]

  ### Prefect Orion API
  orion:
    image: prefecthq/prefect:2-python3.11
    restart: always
    volumes:
      - prefect:/.prefect
    entrypoint: ["prefect", "server", "start"]
    environment:
      - PREFECT_SERVER_API_HOST=0.0.0.0
      - PREFECT_API_DATABASE_CONNECTION_URL=postgresql+asyncpg://prefect:prefect@database:5432/prefect
    ports:
      - 4200:4200
    depends_on:
      - database
    profiles: ["server"]
      
volumes:
  prefect:
  postgres:
  • 在本地访问http://localhost:4200/api
  • 连接失败,截图如下:
    连接失败截图

已尝试的解决方法

  • 修改PREFECT_SERVER_API_HOST为127.0.0.1、公网IP、0.0.0.0均无效
  • 修改为非4200端口无效
  • 尝试访问127.0.0.1:4200、localhost:4200、0.0.0.0:4200均无效
  • 尝试单独构建Dockerfile替代Docker Compose无效

内容的提问来源于stack exchange,提问作者mh_kim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 06:45:04