【发布时间】:2021-05-29 18:12:33
【问题描述】:
我正在运行一个 docker 容器,其中一个 python 应用程序在 host='0.0.0.0' 和端口作为 5050 进行侦听。 当我在 localhost:5000 卷曲我的主站点时,它返回正确的结果。当我 curl localhost:5050 时,它返回
curl: (56) Recv failure: Connection reset by peer
这是我的构建文件
FROM ubuntu:20.04
RUN apt update
RUN apt install -y python3-pip
# Install Dependencies
COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
COPY search_api.py .
COPY search/ search
ENV DEBUG 0
CMD [ "gunicorn", "--workers", "2", "--threads", "1", "-b", "0.0.0.0:5050", "--timeout", "400", "search_api:app"]
我已验证容器正在运行,这些是我返回的日志
[2021-05-29 17:00:43 +0000] [1] [INFO] Starting gunicorn 20.1.0
[2021-05-29 17:00:43 +0000] [1] [INFO] Listening at: http://0.0.0.0:5050 (1)
[2021-05-29 17:00:43 +0000] [1] [INFO] Using worker: sync
[2021-05-29 17:00:43 +0000] [9] [INFO] Booting worker with pid: 9
[2021-05-29 17:00:43 +0000] [10] [INFO] Booting worker with pid: 10
我没有将该文件夹注册为 CPanel 中的应用程序或其他任何东西。我基本上只是在安装 docker 和 docker-compose 后拉取了存储库。然后我开始构建,然后运行容器。这个容器对我来说在本地工作,但我的网络服务器似乎没有在监听它?
如果有人对此有所了解,请帮忙!
【问题讨论】:
-
你是如何启动容器的?
-
我通过在 bash 脚本中进行构建来启动容器,然后使用 docker-compose -f
up
标签: python docker cpanel gunicorn