In one folder I have 3 files: base.py, Dockerfile and docker-compose.yml.
base.py:
import psycopg2
conn = psycopg2.connect(\"dbname=\'b
Add network, link and depends_on configuration in docker compose file.
something like this:
services:
db:
build: .
container_name: db
networks:
- djangonetwork
web:
build: .
depends_on:
- db
links:
- db:db
networks:
- djangonetwork
networks:
djangonetwork:
driver: bridge
the above configuration helped me to resolve the host name to connect to the db.