-
-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot define container hostname #883
Comments
To give some further clarification on why customizing the container hostname is needed:
|
There is a lot of logic that testcontainers does when resolving the host, it doesn't always set it to Perhaps I'm misunderstanding something here, but unless there's a bug in that function, setting the host to anything other than what is returned there would be incorrect. Regardless, there is already support for a If there is some more complex networking requirement, you can create your own network via Testcontainers and set network aliases for each container accordingly. |
While making a PR for this issue, I've come to realise that |
Re: TESTCONTAINERS_HOST_OVERRIDE, I understand that this sets the return value of However looking through the references of The value of testcontainers-node/packages/testcontainers/src/generic-container/generic-container.ts Lines 139 to 146 in 824cd8d
All of this to say, not sure that |
Re: creating a custom network and assigning network alias, this unfortunately didn't work for my particular case Situation
Problem
Proposed Solution 1
Why creating a custom network isn't feasible (AFAIK)
|
It does The situation you're describing should work out of the box. Testcontainers understands that it is running inside a container and set the hostname accordingly. As long as when your NodeJS container is trying to connect to PG it is connecting using the |
I would like to define the container hostname. This is available in the .NET and Java TestContainers frameworks, but not in the NodeJS framework
I understand this is a duplicate of #865 , however on reading the discussion there it is not clear to me what the rationale is for closing that issue :(
My specific use case is that I would like to set up a PostgreSQL container for integration testing in a TypeScript backend. Currently the
container.getHost()
method resolves tolocalhost
and I am not clear how to change this for the PostgreSQL container. This is especially an issue when I need to orchestrate multiple TestContainers for the E2E tests, and the TypeScript backend app itself is using thelocalhost:...
namespace already.The text was updated successfully, but these errors were encountered: