Could not translate host name “db” to address using Postgres, Docker Compose and Psycopg2

后端 未结 6 623
不思量自难忘°
不思量自难忘° 2021-02-01 16:39

In one folder I have 3 files: base.py, Dockerfile and docker-compose.yml.

base.py:

import psycopg2

conn = psycopg2.connect(\"dbname=\'b         


        
6条回答
  •  温柔的废话
    2021-02-01 17:20

    if you add this to your db container in your docker-compose.yml it should resolve the issue

    environment:
      - "POSTGRES_HOST_AUTH_METHOD=trust"
    

提交回复
热议问题