"sudo docker-compuse up"让我冻结/卡在启动工人身上



我正试图让我的docker-compose起来,但它被困与工人启动如果我尝试访问本地主机端口,它只是显示"无法访问该站点"。

Dockerfile:

FROM docker.io/python:3.10
WORKDIR /
# --- [Install python and pip] ---
RUN apt-get update && apt-get upgrade -y && 
apt-get install -y python3 python3-pip git
COPY . /
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install gunicorn
# --- ADDED TIMEOUT FOR FIX ---
ENV GUNICORN_CMD_ARGS="--workers=3 --bind=0.0.0.0:8080 --timeout=1000"
EXPOSE 8080
CMD [ "gunicorn", "main:app" ]

docker-compose文件:

version: '3'
services:
web:
image: runtime_t_v1
build: .
ports:
- "8032:8080"
volumes:
- ./volumes:/volumes
- ./instance:/instance
restart: unless-stopped

错误:

(base) Theo@Theo runtime_flask % sudo docker-compose up
[+] Running 1/0
⠿ Container runtime_flask-web-1  Created                                                                                       0.0s
Attaching to runtime_flask-web-1
runtime_flask-web-1  | [2023-04-07 20:23:34 +0000] [1] [INFO] Starting gunicorn 20.1.0
runtime_flask-web-1  | [2023-04-07 20:23:34 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
runtime_flask-web-1  | [2023-04-07 20:23:34 +0000] [1] [INFO] Using worker: sync
runtime_flask-web-1  | [2023-04-07 20:23:34 +0000] [7] [INFO] Booting worker with pid: 7
runtime_flask-web-1  | [2023-04-07 20:23:34 +0000] [8] [INFO] Booting worker with pid: 8
runtime_flask-web-1  | [2023-04-07 20:23:34 +0000] [9] [INFO] Booting worker with pid: 9

当我查找这个问题时,人们要么在gunicorn上设置超时,要么在Docker上增加内存上限。我两种都试过了,但都不行。您还可以在docker-compose文件中看到我添加到gunicorn的超时。我已经尝试了所有我在网上看到的同样的问题,但没有工作,但也许我只是做错了什么。

从我上次的评论:

  1. 避免以root身份运行docker/docker-compose。您可以将您的用户添加到group = docker。

  2. 如果您运行docker compose up -d(分离),则容器在后台运行。否则,在关闭或取消正在运行的命令时停止它们。

相关内容

  • 没有找到相关文章

最新更新