我有一个docker-compose文件,如下启动psql数据库,目前我正在尝试使用pgAdmin4连接它(不在docker容器中),并且能够查看它。 我一直在尝试验证数据库,但我不明白原因。
docker-compose内容:
version: "3"
services:
# nginx and server also have an override, but not important for this q.
nginx:
ports:
- 1234:80
- 1235:443
server:
build: ./server
ports:
- 3001:3001 # app server port
- 9230:9230 # debugging port
env_file: .env
command: yarn dev
volumes:
# Mirror local code but not node_modules
- /server/node_modules/
- ./server:/server
database:
container_name: column-db
image: 'postgres:latest'
restart: always
ports:
- 5432:5432
environment:
POSTGRES_USER: postgres # The PostgreSQL user (useful to connect to the database)
POSTGRES_PASSWORD: root # The PostgreSQL password (useful to connect to the database)
POSTGRES_DB: postgres # The PostgreSQL default database (automatically created at first launch)
volumes:
- ./db-data/:/var/lib/postgresql/data/
networks:
app-network:
driver: bridge
我输入命令 docker-compose up
后查看日志,显示可以连接。我打开pgAdmin并输入以下信息:
![first screen](https://istack.dev59.com/nW0PF.webp)
其中密码为root
,但是出现了以下错误:
FATAL: password authentication failed for user "postgres"
我检查了Docker日志,发现
DETAIL: Role "postgres" does not exist.
我不确定我做错了什么,按照文档,超级用户应该使用这些规格创建。我是否漏掉了什么?我已经为此苦苦思索了一个小时了。任何帮助都将不胜感激!
Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
。 - OmegaNalphA