【发布时间】:2021-06-11 16:04:53
【问题描述】:
我是 Docker 容器的新手,但对 Postgres 并不陌生(我过去曾深入研究过)。
问题是我正在尝试连接到从以下 Docker 容器 dpage/pgadmin4 启动的 Postgres 服务器
问题是我无法使用 PGAdmin4 连接到服务器。 我收到以下错误:
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Address not available
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
我有以下 yaml 文件:
version: '3'
services:
db:
image: postgres
restart: always
ports:
- "5432:5432"
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: parola
PGDATA: /var/lib/postgresql/data/pgdata
pgadmin4:
image: dpage/pgadmin4
ports:
- "5050:80"
environment:
PGADMIN_DEFAULT_EMAIL: user@domain.com
PGADMIN_DEFAULT_PASSWORD: parola
使用psql命令行我只有设置-h 0.0.0.0才能连接到它,如下:
psql -h 0.0.0.0 -U postgres
谁能告诉我我需要在 yaml 文件中设置什么或如何配置以允许从 localhost/127.0.0.1 连接?
我在 Ubuntu 20.04.2、AMD64 和 Docker 版本 20.10.7 上运行,构建 f0df350。
【问题讨论】:
标签: postgresql docker ubuntu docker-compose pgadmin-4