title: How to connect selenium container to localhost network with test containers?
body: <p>I am trying to integrate selenium into test pipeline of my spring boot application.</p>
  
  <p>During test i run application (using spring boot test), after that testcontainers runs selenium. After that selenium container should run test.</p>
  
  <p>The problem: selenium can’t connect to the host network.</p>
  
  <pre><code>  @SpringBootTest(
      classes = [StatisticServer::class],
      webEnvironment = RANDOM_PORTq)
    @ContextConfiguration(initializers =     [DbTextContextInitializer::class])
    @ActiveProfiles("local", "no-security")
    @Sql(executionPhase = AFTER_TEST_METHOD, scripts = ["classpath:/sql/clear_db.sql"])
  class SeleniumParentTest {
  
  @LocalServerPort
  protected var port=0
  
  class KWebDriverContainer(dockerImage: String) : BrowserWebDriverContainer&lt;KWebDriverContainer&gt;(dockerImage)
  
  var chrome: BrowserWebDriverContainer&lt;*&gt; = KWebDriverContainer("selenium/standalone-chrome-debug:latest")
          .withRecordingMode(BrowserWebDriverContainer.VncRecordingMode.RECORD_ALL, File("build"))
          .withCapabilities(ChromeOptions().setAcceptInsecureCerts(true))
          .withEnv("http_host", "http://192.168.5.46:8080")
          .withNetworkMode("host")
  
  
  @BeforeEach
  fun setUp() {
      chrome.start()
      val driver = chrome.getWebDriver()
      WebDriverRunner.setWebDriver(driver)
  }
  
  @AfterEach
  fun tearDown() {
      WebDriverRunner.closeWebDriver();
  }
  
  @Test
  fun shouldSuccessfullyPassThisTestUsingTheRemoteDriver() {
      open("https://127.0.0.1:9200/swagger-ui.html");
      // open("https://host.docker.internal:$port/swagger-ui.html");
      `$`(By.className("info")).value
      val link = `$`("#res .g", 0).find("a")
  </code></pre>
  
  <p>I tried several ways to solve such issue like adding network mode, use internal docker hostname.</p>
  
  <p>During test execution I get a screenshot with “This site can’t be reached”</p>
  
  <p>I can’t use getTestHostIpAdress() because I use cents.</p>
  
  <p>So, my question is: how to set up testcontainers correctly to be able test web app running locally?</p>