繁体   English   中英

运行时无法到达服务器端点 Docker Compose Python 解释器

[英]Can't reach server endpoints when running Docker Compose Python Interpreter

我在docker-compose.yaml中有一些服务的小设置。 为简洁起见,这是旨在作为主要 API 使用其他服务的服务:

services:

  fprint-api:
    container_name: fprint-api-v2
    image: "fprint-api:v0.0.1"
    depends_on:
      - fprint-svc

    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "8000:8000"

    build:
      context: ../.
      dockerfile: docker/Dockerfile.fprint-api

  # ...

fprint-api有一个简单的健康检查端点,如下所示:

@app.get("/health")
def health():
    return "API OK"

如果我就此运行docker-compose up ,或使用 PyCharm 中的 Docker Compose 运行配置,一切正常,我可以向 http://localhost:8000 发出 GET 请求。

但是,如果我在上述docker-compse.yamlfprint-api服务上使用远程 python 解释器,我将无法再到达此端点。 系统启动,但端点不可访问,因此我无法调试我的端点。

我不确定我到底错过了什么。

远程解释器配置

在此处输入图像描述

fprint-api服务的运行配置

在此处输入图像描述

好的,这是一个简单的。

uvicorn需要将--host标志设置为0.0.0.0才能通过主机名localhost访问 URL:

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM