简体   繁体   English

用户“postgres”的 Docker postgres 9.4 密码认证失败

[英]Docker postgres 9.4 password authentication failed for user “postgres”

I am running very basic docker-compose with following docker-compose.yml and getting following error.我正在运行非常基本的docker-compose并遵循docker-compose.yml并出现以下错误。

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

Error generated,产生错误,

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" 

I checked on various stackoverflow existing questions but none of them are rectifying actual issue.我检查了各种 stackoverflow 现有问题,但没有一个是纠正实际问题。 Some suggesting to run postgres docker and bash it to update the password but its a workaround.有人建议运行 postgres docker 和 bash 它来更新密码,但它是一种解决方法。 Anyone has any concrete solution to this?有人对此有任何具体的解决方案吗?

I figured it out finally and would be good to share what mistake I had done.我终于想通了,很高兴分享我mistake

I changed the database configuration by providing environment variable in the docker-compose.yml file in db service as mentioned in the question already,如问题中所述,我通过在数据库服务的docker-compose.yml文件中提供environment变量来更改数据库配置,

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

But the same needs to be updated in all the other custom services (open source github) which are trying to connect to this depende-on postgres database with same user/password/database which was not done.但同样需要在所有其他自定义服务(开源 github)中更新,这些服务试图使用相同的用户/密码/数据库连接到这个depende-on postgres 数据库,但尚未完成。

However the error given by docker-compose is not explaining the situation clearly.但是 docker-compose 给出的错误并不能清楚地解释情况。

In All, I updated the applications with above username/password/database in connection property and the containers are up.总之,我在连接属性中使用上述用户名/密码/数据库更新了应用程序,并且容器已启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM