testcontainers-java: Browser started by BrowserWebDriverContainer can't connect to localhost

Hi,

In my test I start Tomcat (on localhost) and then use a BrowserWebDriverContainer and do a webDriver.get("http://localhost:8080/...').

In the VNC recording, I can see that the issue is that the docker container running the browser can’t connect to localhost.

Is there a network setup I can use to allow that?

Thanks

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (21 by maintainers)

Most upvoted comments

I’m going to use the following for now:

    private String getHost()
    {
        return SystemUtils.IS_OS_LINUX ? "172.17.0.1" : "host.docker.internal";
    }

Thanks!

PS: I’ll validate with a coworker later on that it does work on Linux 😉