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

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

    Another possible scenario,

    Check if ports have been used or not by other docker container. Use command:

    $ docker container ls --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}" -a
    

    Then change your ports/expose in docker-compose file

提交回复
热议问题