Skip to content

Example needed: exposing host port #1136

@bsideup

Description

@bsideup

It would be nice to add an example of Testcontainers.exposeHostPorts method. It is very helpful when you're running something inside a container but want to access a port from the host.

Let's say:

  1. start a very simple Spring Boot app in the test with some HTML page
  2. use Testcontainers.exposeHostPorts(serverPort) to expose it to the containers network.
  3. start BrowserWebDriverContainer
  4. run some very simple Selenium assertion of the HTML page

Here is a test for the feature:
https://github.com/testcontainers/testcontainers-java/blob/bcecd5cd9f9325517fd45db585312df2624315bb/core/src/test/java/org/testcontainers/containers/ExposedHostTest.java

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions