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

GenericContainer::getHost() returns misleading values across platforms #1

Open
ciaranmcnulty opened this issue Mar 18, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ciaranmcnulty
Copy link
Contributor

When running on MacOS with Docker Desktop for Mac getHost() returns an IP address of the Docker host which is running inside a managed VM. This IP address is not routable from MacOS, so tests fail with timeouts.

My understanding of getHost is that it should return the host at which ports are being exposed, which on MacOS should be localhost.

The Ruby implementation roughly does the following:

  • Use TC_HOST if it is present
  • If DOCKER_HOST or DOCKER_URL are set but not parsable as a URL, use localhost
  • If DOCKER_HOST or DOCKER_URL are set and use a network schema (tcp or http*), use the host portion of that URL
  • If DOCKER_HOST is not set (so would default to local), or is set to a local schema (unix or npipe):
    • If we are in a container (detected via presence of /.dockerenv), use the default gateway
    • If we are not in a container, use localhost

It'd be worth discussing whether that's the same route we should go with in PHP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants