R
R
reqww2020-08-09 19:53:07
Django
reqww, 2020-08-09 19:53:07

Django server not running from docker-compose?

I'm trying to run a django application through docker with a base on postgres
docker-compose.yml:

version: '3.7'

services:
    db:
        image: postgres:latest
        environment: 
            POSTGRES_PASSWORD: 'password'
        volumes:
            - postgres_data:/var/lib/postgresql/data/
    web:
        build: .
        command: python /usr/src/dm_rest/manage.py runserver 0.0.0.0:8000
        volumes:
            - .:/usr/src/dm_rest
        ports: 
            - 8000:8000
        depends_on:
            - db
volumes: 
    postgres_data:

Dockerfile
FROM python:3.8

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

WORKDIR /usr/src/dm_rest

COPY ./req.txt /usr/src/dm_rest
RUN pip install -r /usr/src/dm_rest/req.txt

COPY . /usr/src/dm_rest/


settings.py
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'postgres',
        'USER': 'postgres',
        'PASSWORD': 'password',
        'HOST': 'db',
        'PORT': '5432',
    }
}

As a result, the answer from postgres is this:
5f3029a622690554894439.png
And dzhanga refuses to start the server
5f3029bd60790171687890.png

. What is written incorrectly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
reqww, 2020-08-14
@reqww

In general, for some reason, the server was not at 127.0.0.1:8000, but at the ip of the virtual machine

V
Vitaly Karasik, 2020-08-10
@vitaly_il1

I would start by checking that Popstgres is running and that the database is correct.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question