[Python] Web page won't show up when I run a Dockerized Django project

Discussão em 'Python' iniciado por Stack, Março 9, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to Dockerize a Django project but the webpage won't show up when I run the container. However, I don't get any errors in the terminal when I run docker compose up --build. I've confirmed on Docker Desktop that my container is present and running.

    The error I get is ERR_ADDRESS_INVALID which says the site can't be reached.

    Here is what my Dockerfile looks like:

    FROM python:3

    ENV PYTHONUNBUFFERED=1

    RUN apt-get update && apt-get install -y libpq-dev

    WORKDIR /app

    COPY requirements.txt .

    RUN pip install -r requirements.txt

    COPY . .

    EXPOSE 8000

    CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]


    I tried adding the "0.0.0.0:8000" to CMD but that didn't work either.

    Here's my docker-compose.yml file:

    version: "3"

    services:
    web:
    build:
    context: .
    dockerfile: Dockerfile
    ports:
    - "8000:8000"


    And lastly here is my requirements.txt file:

    asgiref==3.6.0
    Django==4.2.1
    djangorestframework==3.14.0
    psycopg2==2.9.6
    pytz==2023.3
    sqlparse==0.4.4
    tzdata==2023.3



    After looking up the problem online and on YouTube, I'm not sure what the problem is because it seems like I have everything I need.

    Continue reading...

Compartilhe esta Página