如何使用第二个 docker 实例?
How to use a second docker instance?
假设第二个 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
实现
我想你只是拼错了服务器端口环境变量名称,你在第二个命令的开头缺少 PGRST
。
使用 -e PGRST_SERVER_PORT=3002
而不是 -e SERVER_PORT
。
您收到警告是因为 -p
在使用网络主机时被忽略,但这似乎不是问题。无论如何,您可以从命令中删除 -p
设置并仅使用 --net=host
。
假设第二个 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
我想你只是拼错了服务器端口环境变量名称,你在第二个命令的开头缺少 PGRST
。
使用 -e PGRST_SERVER_PORT=3002
而不是 -e SERVER_PORT
。
您收到警告是因为 -p
在使用网络主机时被忽略,但这似乎不是问题。无论如何,您可以从命令中删除 -p
设置并仅使用 --net=host
。