【发布时间】:2021-12-04 09:05:10
【问题描述】:
我将 pgAdmin4 docker 映像拉入我的 linux debian 机器并按照指定的过程 here 配置容器。我运行docker run -p 8000:8000 --env-file ./pgadmin_docker_env.list -d dpage/pgadmin4。为清楚起见,命令中指定的 pgadmin_docker_env.list 包含环境变量::PGADMIN_DEFAULT_EMAIL=my_email@example.com PGADMIN_DEFAULT_PASSWORD=my_password。当容器以分离模式运行时,我在 Web 浏览器中运行 localhost:8080 以在服务器模式下访问 pgAdmin 4。但是,我无法从 pgadmin 内部创建到 localhost postgres 数据库的服务器连接。输入连接参数后出现以下错误(如下图所示)
Unable to connect to server: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections?
更新 我用 host.docker.internal 代替了 localhost,但仍然出现错误
Unable to connect to server: could not translate host name "host.docker.internal" to address: Name does not resolve
【问题讨论】:
-
您要连接到哪个
localhost? (容器外的主机系统;pgadmin 容器;单独的 PostgreSQL 容器;我的笔记本电脑?所有这些东西单独认为它们是localhost) -
主机系统localhost
标签: postgresql docker containers database-connection pgadmin-4