Reputation: 372
I am deploying two Testcontainers, one with an image of PostgreSQL (12.0) and another one with Keycloak (8.0.0).
The PostgreSQL one starts successfully, but when the Keycloak one tries to connect to PostgreSQL returns a connection refused.
I put all the environment variables to Keycloak to connect to that PostgreSQL container
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);
where ${DB_PORT} is the port where the PostgreSQL is deployed and the DB_ADDR is the alias that PostgreSQL container has in a network that I made, where are both containers.
Am I missing something? Has anyone tried too with success?
Thanks in advance.
Upvotes: 0
Views: 1007
Reputation: 3063
${DB_PORT}
must be 5432
, since you connect directly to the container and not through the exposed port.
Upvotes: 1