Skip to content
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

Running container inside container with custom network returns wrong gateway address #683

Closed
HofmeisterAn opened this issue Nov 22, 2022 · 4 comments · Fixed by #692
Closed
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@HofmeisterAn
Copy link
Collaborator

HofmeisterAn commented Nov 22, 2022

Testcontainers returns the wrong gateway address if a container is running "inside" another container and has a custom network assigned. The current implementations just looks for networks with the name bridge:

var endpointSettings = this.container.NetworkSettings.Networks.TryGetValue("bridge", out var network) ? network : new EndpointSettings();

Originally posted by @ricardofmfreitasMP in #679 (comment)

@HofmeisterAn HofmeisterAn added enhancement New feature or request help wanted Extra attention is needed labels Nov 22, 2022
@kiview
Copy link
Member

kiview commented Nov 23, 2022

This is interesting. In this case, I would expect the same issue for testcontainers-java. Can you conceptionally share a reproducer for us? (.NET reproducer is also fine, we can port it)

@HofmeisterAn
Copy link
Collaborator Author

HofmeisterAn commented Nov 23, 2022

That's my test example. L75 contains the "workaround".

@HofmeisterAn
Copy link
Collaborator Author

HofmeisterAn commented Nov 23, 2022

@kiview @eddumelendez @mdelapenya Do we know why we have the limitation and only consider networks with the name bridge? I know bridge is default, but what do we return in case of someone assigns a custom network?

@kiview
Copy link
Member

kiview commented Nov 23, 2022

To add some context, I tracked the changes in testcontainers-java. This behavior was introduced through testcontainers/testcontainers-java#2151.

Before, we did a more manual and dynamic lookup using this method, leveraging a running container:
https://github.com/testcontainers/testcontainers-java/blob/de1324ed2800eff4da326d0c23d281399d006bc0/core/src/main/java/org/testcontainers/dockerclient/DockerClientConfigUtils.java#L20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants