gpt4 book ai didi

java - Testcontainer Keycloak 无法连接到 Testcontainer PostgreSQL

转载 作者:行者123 更新时间:2023-12-02 08:45:36 30 4
gpt4 key购买 nike

我正在部署两个 Testcontainer,一个带有 PostgreSQL (12.0) 镜像,另一个带有 Keycloak (8.0.0)。

PostgreSQL启动成功,但是当Keycloak尝试连接PostgreSQL时返回连接被拒绝。

我将所有环境变量放入 Keycloak 以连接到该 PostgreSQL 容器

withEnv("DB_VENDOR", "postgres");
withEnv("DB_DATABASE", KeycloakDS);
withEnv("DB_SCHEMA", test);
withEnv("DB_USER", postgres);
withEnv("DB_PASSWORD", keycloak);
withEnv("DB_ADDR", postgres);
withEnv("DB_PORT", ${DB_PORT});
withEnv("KEYCLOAK_USER", admin);
withEnv("KEYCLOAK_PASSWORD", admin);

其中${DB_PORT}是部署PostgreSQL的端口,DB_ADDR是PostgreSQL容器在我创建的网络中的别名,两个容器都在哪里。

我错过了什么吗?有人也尝试过成功吗?

提前致谢。

最佳答案

${DB_PORT} 必须是 5432,因为您直接连接到容器,而不是通过公开的端口。

关于java - Testcontainer Keycloak 无法连接到 Testcontainer PostgreSQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61105722/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com