Linux Odoo容器:数据库连接失败:无法连接到服务器:连接被拒绝(将Odoo与本地主机postgres链接)

Linux Odoo容器:数据库连接失败:无法连接到服务器:连接被拒绝(将Odoo与本地主机postgres链接),linux,docker,odoo,Linux,Docker,Odoo,我正在尝试运行odoo docker容器并将其与本地(非容器)postgresql链接。 我尝试了此命令(如建议)。 运行它并得到以下错误: Database connection failure: 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? c


我正在尝试运行odoo docker容器并将其与本地(非容器)postgresql链接。
我尝试了此命令(如建议)。

运行它并得到以下错误:

Database connection failure: 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: Cannot assign requested address
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
我试图用ufw打开5432端口,但也遇到了同样的错误。我还尝试将127.0.0.1更改为0.0.0.0,但没有任何更改。
你能帮我吗


ps:用户和密码是正确的,我在本地运行odoo实例时使用它们。

您可能需要添加带有标志的主机网络
--network=host

警告:使用主机网络模式时,将丢弃已发布的端口

这只意味着您不能更改端口绑定。这和您的计算机一样安全。

您可能需要添加带有标志的主机网络
--network=host
@ErikK,但收到了“警告:使用主机网络模式时已发布的端口被丢弃”,这是安全问题吗?嘿,如果您能接受我的回答,那就太好了。谢谢
Database connection failure: 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: Cannot assign requested address
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?