EC2上使用docker-compose的用户“ postgres”的密码身份验证失败

时间:2019-04-13 16:28:19

标签: postgresql docker amazon-ec2 docker-compose docker-machine

在由docker-machine创建的EC2 linux服务器上,当我通过 docker-compose up 启动docker postgres:10.6时,出现以下循环错误:

FATAL:  password authentication failed for user "postgres"
DETAIL:  Password does not match for user "postgres".
Connection matched pg_hba.conf line 95: "host all all all md5"

如果我手动启动容器,我没有这些错误 => docker run -e POSTGRES_PASSWORD = myPassword postgres:10.6

我在本地docker中没有这些错误

我的docker-compose:

  db:
    container_name: postgres
    image: postgres:10.6
    restart: always
    environment:
      POSTGRES_PASSWORD: myPassword
    ports:
      - "5432:5432"

有人想解决这个问题吗(我被困了两天)?

2 个答案:

答案 0 :(得分:0)

可能是因为首次启动后已初始化了卷(或绑定安装目录)。 postgres用户,并且数据库创建仅在第一次启动时发生(即/ var / lib / postgresql / data必须已经不包含数据库文件)。 尝试运行:

  • docker-compose rm -fv postgres删除所有容器或卷(尤其是)。
  • docker-compose up -d启动容器。

答案 1 :(得分:0)

对不起,我已经回答了我的问题,这不是错误,我只是尝试将其永久连接到postgres(通过开放的端口5432)...

搜索后,我认为这是一次黑客尝试,因为传入连接永远不会来自同一IP

connection received: host=45.120.120.149.81 port=47118
connection received: host=210.4.125.252 port=44774
connection received: host=82.223.55.254 port=36320

等...

相关问题