小编ryo*_*ake的帖子

docker-compose 中的快速 api 和 nginx 在连接到上游时显示 connect() 失败(111:连接被拒绝),客户端:172.27.0.1,服务器:

fastapi nginx 模板

\n

源代码

\n

它是快速的 api 和 nginx 模板,但目前它不能按我的预期工作。\n当你卷曲本地主机时,它响应 502 bad gateway instaed of hello world 这是在 main.py 中定义的...

\n

docker 日志 web 显示connect() failed (111: Connection refused) while connecting to upstream, client: 172.27.0.1, server:在 nginx 容器中。

\n

但为什么 ??你如何修复这个错误?

\n

文件树

\n
.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Dockerfile\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 README.md\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 docker-compose.yml\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 main.py\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 nginx\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Dockerfile\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 nginx.conf\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 requirements.txt\n
Run Code Online (Sandbox Code Playgroud)\n

构建并启动

\n
    \n
  1. docker-compose up -d --build

    \n
  2. \n
  3. docker logs ps -a

    \n
  4. \n
\n
CONTAINER ID   IMAGE                         COMMAND                  CREATED …
Run Code Online (Sandbox Code Playgroud)

nginx docker dockerfile docker-compose fastapi

2
推荐指数
1
解决办法
2817
查看次数

标签 统计

docker ×1

docker-compose ×1

dockerfile ×1

fastapi ×1

nginx ×1