docker 您访问的页面不存在

liwlm1x9  于 2023-06-29  发布在  Docker
关注(0)|答案(1)|浏览(123)

我以这种方式运行postgresql(根据此指令https://hevodata.com/learn/docker-postgresql/

docker run --name postgres3 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres1 -e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432 -v /data:/var/lib/postgresql/data -d postgres

而不是尝试连接,但失败,并显示以下日志:

└─$ docker logs 99691c70698b

PostgreSQL Database directory appears to contain a database; Skipping initialization

2023-06-09 13:58:38.652 UTC [1] LOG:  starting PostgreSQL 15.3 (Debian 15.3-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2023-06-09 13:58:38.653 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-06-09 13:58:38.653 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-06-09 13:58:38.662 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-06-09 13:58:38.670 UTC [29] LOG:  database system was shut down at 2023-06-09 13:58:04 UTC
2023-06-09 13:58:38.677 UTC [1] LOG:  database system is ready to accept connections
2023-06-09 13:58:43.492 UTC [33] LOG:  invalid length of startup packet
2023-06-09 13:58:52.636 UTC [34] FATAL:  password authentication failed for user "postgres"
2023-06-09 13:58:52.636 UTC [34] DETAIL:  Role "postgres" does not exist.
        Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2023-06-09 14:03:30.404 UTC [44] FATAL:  password authentication failed for user "postgres"
2023-06-09 14:03:30.404 UTC [44] DETAIL:  Role "postgres" does not exist.
        Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
2023-06-09 14:03:38.766 UTC [27] LOG:  checkpoint starting: time
2023-06-09 14:03:38.783 UTC [27] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.006 s, sync=0.003 s, total=0.018 s; sync files=2, longest=0.002 s, average=0.002 s; distance=0 kB, estimate=0 kB
2023-06-09 14:19:14.076 UTC [76] LOG:  invalid length of startup packet
2023-06-09 14:21:32.667 UTC [82] FATAL:  password authentication failed for user "postgres"
2023-06-09 14:21:32.667 UTC [82] DETAIL:  Role "postgres" does not exist.
        Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"

我做错了什么?什么是“角色postgres”?如何正确安装容器化的Postgres 15.x?

**UPD:**Postgres是通过“docker pull postgres”安装的

s4n0splo

s4n0splo1#

问题是“-ePOSTGRES_USER=postgres”选项。它运行良好,没有它(默认用户是postgres)。初始启动必须没有“-e POSTGRES_USER=postgres”

相关问题