17 days ago
Please helpe-me my project python / django
Dockerfile:24
Jun 22 04:05:13
-------------------
Jun 22 04:05:13
22 | # build phase
Jun 22 04:05:13
23 | COPY . /app/.
Jun 22 04:05:13
24 | >>> RUN web: gunicorn canguinaProject.wsgi:application --bind 0.0.0.0:$PORT
Jun 22 04:05:13
25 |
Jun 22 04:05:13
26 |
Jun 22 04:05:13
-------------------
Jun 22 04:05:13
ERROR: failed to solve: process "/bin/bash -ol pipefail -c web: gunicorn canguinaProject.wsgi:application --bind 0.0.0.0:$PORT" did not complete successfully: exit code: 127
Jun 22 04:05:13
Error: Docker build failed
4 Replies
17 days ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open chandrika • 17 days ago
17 days ago
You're getting an error in your Docker build due to a misuse of a command in the Dockerfile
:
Problem line:
RUN web: gunicorn canguinaProject.wsgi:application --bind 0.0.0.0:$PORT
Explanation:
RUN
is used to run commands during the image build time, like installing packages.You're using a command like
web: gunicorn ...
, which looks like a Procfile entry (used by Heroku), not valid shell syntax.The
web:
prefix is not valid in a Dockerfile.
Correct Usage:
You should replace that line with:
Option 1: Use in CMD or ENTRYPOINT (Recommended for Django + Gunicorn)
CMD ["gunicorn", "canguinaProject.wsgi:application", "--bind", "0.0.0.0:8000"]
Then make sure your Dockerfile
ends with that (and remove the broken RUN
line).
Fixed Example Dockerfile Tail:
# ... other Dockerfile content above
COPY . /app/
WORKDIR /app
# Expose the port
EXPOSE 8000
# Start Gunicorn
CMD ["gunicorn", "canguinaProject.wsgi:application", "--bind", "0.0.0.0:8000"]
Replace
8000
with your$PORT
if it's provided at runtime via environment variables.
If you must use $PORT
from environment:
Modify like this:
CMD exec gunicorn canguinaProject.wsgi:application --bind 0.0.0.0:${PORT:-8000}
Use ENTRYPOINT
or shell form CMD
to expand environment variables.
17 days ago
So, i need create a Dockerfile file to fix it, ok?
17 days ago
Hi, i try with my Dockerfile follow
# Imagem base com Python 3.11.9
FROM python:3.11.9-slim
# Evita prompts durante instalação de pacotes
ENV DEBIAN_FRONTEND=noninteractive
# Diretório de trabalho
WORKDIR /app
# Copia o requirements.txt e instala dependências
COPY requirements.txt ./
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copia o restante da aplicação
COPY . .
# Variável de ambiente padrão para Django
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Expõe a porta (usada localmente ou por $PORT via CMD)
EXPOSE 8000
# Comando para iniciar o Gunicorn (usa $PORT se disponível, ou 8000)
CMD ["gunicorn", "canguinaProject.wsgi:application", "--bind", "0.0.0.0:$PORT"]
But after deploy throw this err:
You reached the start of the range → Jun 22, 2025 3:20 PM
--
Starting Container
--
--
Error: '$PORT' is not a valid port number.
--
--
--
Error: '$PORT' is not a valid port number.
--
ujjwaljha1
You're getting an error in your Docker build due to a misuse of a command in the Dockerfile:Problem line:RUN web: gunicorn canguinaProject.wsgi:application --bind 0.0.0.0:$PORTExplanation:RUN is used to run commands during the image build time, like installing packages.You're using a command like web: gunicorn ..., which looks like a Procfile entry (used by Heroku), not valid shell syntax.The web: prefix is not valid in a Dockerfile.Correct Usage:You should replace that line with:Option 1: Use in CMD or ENTRYPOINT (Recommended for Django + Gunicorn)CMD ["gunicorn", "canguinaProject.wsgi:application", "--bind", "0.0.0.0:8000"]Then make sure your Dockerfile ends with that (and remove the broken RUN line).Fixed Example Dockerfile Tail:# ... other Dockerfile content above COPY . /app/ WORKDIR /app # Expose the port EXPOSE 8000 # Start Gunicorn CMD ["gunicorn", "canguinaProject.wsgi:application", "--bind", "0.0.0.0:8000"]Replace 8000 with your $PORT if it's provided at runtime via environment variables.If you must use $PORT from environment:Modify like this:CMD exec gunicorn canguinaProject.wsgi:application --bind 0.0.0.0:${PORT:-8000}Use ENTRYPOINT or shell form CMD to expand environment variables.
17 days ago
Solved ! Your solution done!
Status changed to Open chandrika • 17 days ago