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

后端 未结 6 638
不思量自难忘°
不思量自难忘° 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:27

    Changing the host from "db" to "postgres" worked for me.

    Also use postgres defaults for username and password which is

    username: postgres
    password:
    

提交回复
热议问题