我在撰写文件时连接到PG数据库时遇到问题。我最终消除了所有其他因素并使这个简单的组成文件:
version: '2.1'
services:
database:
image: postgres:9.5.6
environment:
POSTGRES_PASSWORD: secretpass
ports:
- 5432:5432
然后我用这个命令启动它:
docker-compose --file docker-compose.pg.yml up --build
似乎开始好了:
Starting app_database_1 ...
Starting app_database_1 ... done
Attaching to app_database_1
database_1 | LOG: database system was shut down at 2017-09-22 18:48:55 UTC
database_1 | LOG: MultiXact member wraparound protections are now enabled
database_1 | LOG: database system is ready to accept connections
database_1 | LOG: autovacuum launcher started
然后从另一个shell尝试连接此命令:
psql postgresql://postgres:secretpass@0.0.0.0
在我的第一个运行compose的shell上输出了这个输出:
database_1 | FATAL: password authentication failed for user "postgres"
database_1 | DETAIL: Connection matched pg_hba.conf line 95: "host all all 0.0.0.0/0 md5"
我还尝试从另一个运行的容器连接 在compose文件中定义Rails并获得相同的错误。我总是遇到身份验证错误。我错过了什么?