Page is not working after using Docker

Asked

Viewed 20 times

-1

I created a web application with Django and when I run the command "python Manage.py runserser" the page runs normally. But after running the Docker container the page appears as not working:

Docker-Compose up -d

Creating network "devbook_default" with the default driver
Creating mongodb_container ... done
Creating devbook_web_1     ... done

Dockerfile:

    FROM python:3.9

    ENV PYTHONDONTWRIETBYTECODE 1
    ENV PYTHONNUMBUFFERED 1
    
    WORKDIR /projeto
    
    COPY requirements.txt .
    RUN pip install -r requirements.txt
    
    COPY . .

Docker-Compose.yml

version: "3.8"

services:
  web:
    build: .
    command: python manage.py runserver
    volumes:
      - .:/code
    ports:
      - 8000:8000
    depends_on:
      - db
  db:
    image: mongo
    container_name: mongodb_container
    ports:
    - "27017:27017"
    environment:
      - MONGO_INITDB_ROOT_NAME=Devbook
    volumes:
      - /data/db:/data/db

Using the Docker-Compose ps

Name                    Command             State                      Ports
------------------------------------------------------------------------------------------------------
devbook_web_1       python manage.py runserver    Up      0.0.0.0:8000->8000/tcp,:::8000->8000/tcp
mongodb_container   docker-entrypoint.sh mongod   Up      0.0.0.0:27017->27017/tcp,:::27017->27017/tcp

When access to localhost:8000 page appears like this: inserir a descrição da imagem aqui

  • Please clarify your problem or provide additional details in order to highlight exactly what you need. The way it’s written these days it’s hard to tell exactly what you’re asking.

  • Could you try accessing the IP address? For example: <192.168.0.6>:8000. Subistutuir at your address ipv4.

  • Another attempt you could make is to change the command to start the Django application, in the Docker-Compose file, to change the line: command: python manage.py runserver 0.0.0.0:8000

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.