Docker postgres 9.4 密码身份验证失败的用户"postgres"



我运行非常基本的docker-compose与以下docker-compose.yml并得到以下错误。

docker-compose.yml

services:
redis:
image: redis
db:
image: postgres:9.4
environment:
- POSTGRES_USER=udcoker
- POSTGRES_PASSWORD=udcoker
- POSTGRES_DB=docker
vote:
image: voting-app
ports:
- 5000:80
depends_on:
- redis
worker:
image: worker-app
depends_on:
- redis
- db
environment:
- POSTGRES_USER=udcoker
- POSTGRES_PASSWORD=udcoker
- POSTGRES_DB=docker
result:
image: result-app
ports:
- 5001:80
depends_on:
- db
environment:
- POSTGRES_USER=udcoker
- POSTGRES_PASSWORD=udcoker
- POSTGRES_DB=docker

错误产生,

db_1      | vacuuming database template1 ... ok
db_1      | copying template1 to template0 ... ok
db_1      | copying template1 to postgres ... ok
db_1      | syncing data to disk ...
db_1      | WARNING: enabling "trust" authentication for local connections
db_1      | You can change this by editing pg_hba.conf or using the option -A, or
db_1      | --auth-local and --auth-host, the next time you run initdb.
db_1      | ok
db_1      |
db_1      | Success. You can now start the database server using:
db_1      |
db_1      |     postgres -D /var/lib/postgresql/data
db_1      | or
db_1      |     pg_ctl -D /var/lib/postgresql/data -l logfile start
db_1      |
db_1      | waiting for server to start....LOG:  database system was shut down at 2021-03-03 12:45:13 UTC
db_1      | LOG:  MultiXact member wraparound protections are now enabled
db_1      | LOG:  database system is ready to accept connections
db_1      | LOG:  autovacuum launcher started
worker_1  | Waiting for db
result_1  | Waiting for db
db_1      |  done
db_1      | server started
db_1      | CREATE DATABASE
db_1      |
db_1      |
db_1      | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
db_1      |
db_1      | LOG:  received fast shutdown request
db_1      | LOG:  aborting any active transactions
db_1      | LOG:  autovacuum launcher shutting down
db_1      | waiting for server to shut down....LOG:  shutting down
db_1      | LOG:  database system is shut down
worker_1  | Waiting for db
result_1  | Waiting for db
db_1      |  done
db_1      | server stopped
db_1      |
db_1      | PostgreSQL init process complete; ready for start up.
db_1      |
db_1      | LOG:  database system was shut down at 2021-03-03 12:45:15 UTC
db_1      | LOG:  MultiXact member wraparound protections are now enabled
db_1      | LOG:  database system is ready to accept connections
db_1      | LOG:  autovacuum launcher started
db_1      | FATAL:  password authentication failed for user "postgres"
db_1      | DETAIL:  Connection matched pg_hba.conf line 95: "host all all all md5"
db_1      | FATAL:  password authentication failed for user "postgres"
db_1      | DETAIL:  Connection matched pg_hba.conf line 95: "host all all all md5" 

我检查了各种stackoverflow存在的问题,但没有一个是纠正实际问题。有人建议运行postgres docker并bash它来更新密码,但这是一个解决方案。有人有具体的解决办法吗?

我终于弄明白了,将很好地分享我所做的mistake

我通过在db服务的docker-compose.yml文件中提供environment变量来更改数据库配置,如问题中已经提到的,

environment:
- POSTGRES_USER=udcoker
- POSTGRES_PASSWORD=udcoker
- POSTGRES_DB=docker

但是同样需要在所有其他自定义服务(开源github)中更新,这些服务试图连接到具有相同用户/密码/数据库的depende-onpostgres数据库,而这些数据库没有完成。

然而,docker-compose给出的错误并没有清楚地解释情况。

在所有的应用程序中,我在连接属性中更新了上述用户名/密码/数据库的应用程序,并且容器已经启动。

相关内容

  • 没有找到相关文章