I need to connect to existing db in my computer. When I create db service with postgis image, it creates a new database inside docker container. But I need to connect to my local one. Is it possible? docker-compose.yml :
version: '3'
services:
build: ./
command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py collectstatic --noinput --i rest_framework && gunicorn orion-amr.wsgi:application --bind 0.0.0.0:8000 --workers=2"
ports:
- "${webport}:8000"
env_file:
- ./.env
settings.py :
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': os.environ.get('pgdatabase'),
'USER': os.environ.get('pguser'),
'PASSWORD': os.environ.get('pgpassword'),
'HOST': os.environ.get('pghostname'),
'PORT': '5432',
}
}
.env file:
pgport=5432
webport=8000
SECRET_KEY=z)mf(y#w7-_8y1)0(v*n@w@lzf)!0=g_rj5$%1w6g-t!7nbk05
pgdatabase=amr_or
pgpassword=root
pghostname=localhost
pguser=postgres
DEBUG=
Now I have this error:
web_1 | django.db.utils.OperationalError: could not connect to server: Connection refused
web_1 | Is the server running on host "localhost" (127.0.0.1) and accepting
web_1 | TCP/IP connections on port 5432?
web_1 | could not connect to server: Cannot assign requested address
web_1 | Is the server running on host "localhost" (::1) and accepting
web_1 | TCP/IP connections on port 5432