-
Notifications
You must be signed in to change notification settings - Fork 141
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
Allow providing a network alias #252
Comments
The name of the container can be set per Docker has many features and am I not planning on exposing all of them through testcontainers unless they provide significant value to using containers in test environments. |
The difference would be that you can have the same name (e.g This prevents you from running multiple tests in parallel. |
Thank you for the explanation!
Running multiple tests is parallel is something we want to definitely support and is in fact one of the main reasons we created testcontainers-rs! From your description, it sounds like the primary thing a user would want to control is the network alias and not the container name? I am trying to minimize the configuration options a user needs to understand and having both, container name and network alias was at least confusing to me. Do you think it would be acceptable to remove the Can you think of a usecase within testcontainers in which you would want to specifically control the container name and not the network alias? From what I can see, a container's name is primarily useful as an identifier for managing the lifecycle of the container (start, stop, etc). Given that we do this for the user in testcontainers, I am inclined to remove the |
I see your point. I am not sure, though if removing an existing parameter is a good idea :) But I also don't see any real reason to use a name, as you can "get" the ID of the container, if you need to access it from the tests (like shelling into the container). Maybe other people have different opinions or more insight into this. |
I am leaning towards replacing If someone comes up with a usecase for Happy to merge a PR that replaces |
Is this issue still open? I am happy to take a look |
Yes, still open! Let me know if you have any questions :) |
Hello everyone who is interested in this issue! Status update for this task:
We could go with such approach:
However, there is a missing fact here, not mentioned before: aliases belongs to the network, not to the container (i.e container may have different aliases across different networks). Instead, we can consider such approach:
Thus, we have the following benefits:
|
The argument
--network-alias
may be used to influence the name of container in the docker network. Otherwise the container is only available by its ID or name.It would be useful, if you want to orchestrate a few test containers, which need to communicate with each other, to allow providing the network alias, in order to have predictable DNS names. Compared to using the ID or name (which might clash).
The text was updated successfully, but these errors were encountered: