0

假设第二个 docker 实例的命令是

docker run --rm --net=host -p 3002:3002 -e SERVER_PORT="3002" \
 -e PGRST_DB_URI="postgres://postgres@localhost/prod2"    \
 -e PGRST_DB_ANON_ROLE="postgres" postgrest/postgrest

结果

WARNING: Published ports are discarded when using host network mode
Attempting to connect to the database...
Listening on port 3000
postgrest: Network.Socket.bind: resource busy (Address already in use)

这没有任何意义,因为使用-p 3002:3002 -e SERVER_PORT="3002"... 是否可以运行?配置错误在哪里?

注意:第一个 docker 是由docker run -d --net=host -p 3000:3000 -e PGRST_DB_URI="postgres://postgres@localhost/prod0" -e PGRST_DB_ANON_ROLE="postgres" postgrest/postgrest


另请参阅https://github.com/PostgREST/postgrest/issues/1442

4

1 回答 1

1

我认为您只是拼错了服务器端口环境变量名称,您PGRST从第二个命令的开头就丢失了。

使用-e PGRST_SERVER_PORT=3002而不是-e SERVER_PORT.

您会收到警告,因为-p在使用网络主机时会被忽略,但这似乎不是问题。无论如何,您可以-p从命令中删除设置并使用--net=host.

于 2020-01-30T20:11:48.973 回答