I am trying to containerize a python app and it has a postgres db which is in GCP cloud. But when I build the app its throwing an error telling the database does not exist i am unable to understand what is happening i can connect to the database by using Dbeaver tool but when I run the docker file the container is up but has some error logs. I have added the public ip of my laptop in gcp sql connections but unable to understand why it throws this error
I can see the logs that say
File "/usr/local/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 187,
in get_new_connection
connection = Database.connect(**conn_params)
File "/usr/local/lib/python3.9/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL: database "test-instance" does not exist
Docker file which i used
# Pull base image
FROM python:3.9
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Set work directory
WORKDIR /code
# Install dependencies
COPY requirements.txt /code/
RUN pip install -r requirements.txt
# Copy project
COPY . /code/
settings.py file how i reach out to the gcp db
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'test-instance',
'USER': 'postgres',
'PASSWORD': 'abcder',
'HOST': '35.224.136.9',
'PORT': '5432',
}
}