В итоге рабочая конфигурация такая
docker-compose.yml
version: '3.7'
services:
web:
build: .
command: python /profi/manage.py runserver 0.0.0.0:8000
environment:
# DJANGO_SETTINGS_MODULE: "project.settings.development"
DEBUG: 1
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_HOST: db
volumes:
- .:/profi
ports:
- "${HTTP_PORT:-8000}:8000"
depends_on:
- db
db:
image: postgres:11
volumes:
- postgres_data:/var/lib/posgresql/data/
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_HOST: db
ports:
- "${DB_PORT:-5432}:5432"
volumes:
postgres_data:
settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ.get('POSTGRES_DB', default='postgres'),
'USER': os.environ.get('POSTGRES_USER', default='postgres'),
'PASSWORD': os.environ.get('POSTGRES_PASSWORD', default='postgres'),
'HOST': os.environ.get('POSTGRES_HOST', default='localhost'),
'PORT': "5432"
}
}