Skip to content

Accessing host from container #447

Answered by HofmeisterAn
g0loob asked this question in Q&A
Discussion options

You must be logged in to vote

I think for Linux, there is no default DNS name. I don't know much about the GitLab environment, but if you have a running container, you should get the host address from the Hostname property:

https://github.com/HofmeisterAn/dotnet-testcontainers/blob/de4c4a251152ee2cfdcd4061c8b1bcc0621e692f/src/DotNet.Testcontainers/Containers/TestcontainersContainer.cs#L85

If your service listens on 0.0.0.0, you should be able to access it. The Kafka configuration, for instance, uses the property during the container start to configure it own services:

https://github.com/HofmeisterAn/dotnet-testcontainers/blob/de4c4a251152ee2cfdcd4061c8b1bcc0621e692f/src/DotNet.Testcontainers/Configurations/Modules/Mes…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@g0loob
Comment options

Answer selected by g0loob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants