我已经安装了一个带有docker的parse-server实例。我的数据库在主机上,但当我运行docker时,它显示为error on connecting to the DB.
docker run -t -d --name parse-server parseplatform/parse-server --appName appname --appId appid--masterKey masterkey --clientKey clientkey --databaseURI postgres://example:1234563@localhost/parse-server --serverURL http://sync.example.com:1337/parse --verbose --publicServerURL http://sync.example.com我得到了这个错误:
Error: connect ECONNREFUSED 127.0.0.1:5432
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5432
}我尝试使用--network host,但是解析服务器使用这个docker给出了{"error":"unauthorized"}。
我也尝试使用-o 5432:5432,但它显示端口已使用,因为实例在主机上运行。
如果不使用--network host,如何从docker解析服务器连接到主机上的PostgreSQL
发布于 2020-07-31 15:16:49
问题是127.0.0.1不是你的主机本地主机地址,而是docker的本地主机地址。
因此,您有不同的选择,但尝试将解析服务器连接到通过docker网络连接的主机地址:172.17.0.X可能更好。
在您的主机上执行ifconfig并查看您的docker网络的IP地址,然后尝试将其放入您的命令中:
docker run -t -d --name parse-server parseplatform/parse-server --appName appname --appId appid--masterKey masterkey --clientKey clientkey --databaseURI postgres://example:1234563@YOUR_HOST_IP_IN_DOCKER_INTERFACE/parse-server --serverURL http://sync.example.com:1337/parse --verbose --publicServerURL http://sync.example.comhttps://stackoverflow.com/questions/63186064
复制相似问题