I'm trying to get my docker-compose up but it gets stuck with the workers booting If I try to go to the local host port it just shows "The site can't be reached" page as well
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" ]
My docker-compose file:
version: '3'
services:
web:
image: runtime_t_v1
build: .
ports:
- "8032:8080"
volumes:
- ./volumes:/volumes
- ./instance:/instance
restart: unless-stopped
This is the error:
(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
When I looked up the problem, people either put a timeout on gunicorn or increased their memory cap on Docker. I tried both but neither work. You can also see the timeout I added to gunicorn within my docker-compose file. I've tried everything I've seen online with the same problem but nothing has worked but maybe I'm just doing something wrong.
From my last comment:
Avoid run docker / docker-compose as root. You could add your user to group = docker.
If you run docker compose up -d
(detach) the containers run in the background. Otherwise, you stop them when close or cancel the running command.