Odoo容器:数据库连接失败:无法连接到服务器:连接被拒绝(将odoo与localhost postgres链接)

时间:2020-01-24 08:29:38

标签: linux docker odoo


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

docker container run -p 8089:8069 -e HOST=127.0.0.1 -e USER=tux -e PASSWORD=tux --name odoo -t odoo

运行它并得到以下错误:

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:USER和PASSWORD是正确的,我在本地运行odoo实例时会使用它们。

1 个答案:

答案 0 :(得分:2)

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

WARNING: Published ports are discarded when using host network mode 这仅表示您无法更改端口绑定。那就是您的机器一样安全。