--bind 0.0.0.0:$PORT" did not complete successfully: exit code: 127 Error: Docker build failed
acciolymab
PROOP

8 months 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

$10 Bounty

4 Replies

chandrika
EMPLOYEE

8 months 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 8 months ago


ujjwaljha1
FREE

8 months ago

You're getting an error in your Docker build due to a misuse of a command in the Dockerfile:

x emoji Problem line:

RUN web: gunicorn canguinaProject.wsgi:application --bind 0.0.0.0:$PORT

mag emoji 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.

white_check_mark emoji 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).

white_check_mark emoji 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.

white_check_mark emoji 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.


acciolymab
PROOP

8 months ago

So, i need create a Dockerfile file to fix it, ok?


acciolymab
PROOP

8 months 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

Jun 22 15:26:27

a3b0e8b2

web

--

837dfff2

Starting Container

Jun 22 15:26:28

a3b0e8b2

web

--

837dfff2

Jun 22 15:26:28

a3b0e8b2

web

--

837dfff2

Error: '$PORT' is not a valid port number.

Jun 22 15:26:28

a3b0e8b2

web

--

837dfff2

Jun 22 15:26:28

a3b0e8b2

web

--

837dfff2

Jun 22 15:26:28

a3b0e8b2

web

--

837dfff2

Error: '$PORT' is not a valid port number.

Jun 22 15:26:28

a3b0e8b2

web

--

837dfff2


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.

acciolymab
PROOP

8 months ago

Solved ! Your solution done!


Status changed to Open chandrika 8 months ago


Loading...