I have a project in Django, I want to configure my docker with an existing postgres database, but the tutorials I see are from a database without data.
who could give me a guide, please
It's my set up
Docker-compose:
services:
web:
build: .
command: python3 manage.py migrate
command: python3 manage.py runserver 0.0.0.0:8000
ports:
- "8000:8000"
volumes:
- .:/code
depends_on:
- db
db:
image: postgres
Docker file
FROM python:3.9
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY . /code
RUN pip install -r requirements.txt
File setting in django project
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME':'postgres',
'USER': 'postgres',
'HOTS': 'db',
'PORT': 5432,
}
}