@Test
    public void testFixedHostPortMapping() throws IOException {
        // first find a free port on the docker host that will work for testing
        final Integer unusedHostPort;
        try (
            final GenericContainer echoServer = new GenericContainer(TestImages.TINY_IMAGE)
                .withExposedPorts(TEST_PORT)
                .withCommand("/bin/sh", "-c", HTTP_ECHO_CMD)
        ) {
            echoServer.start();
            unusedHostPort = echoServer.getMappedPort(TEST_PORT);
        }

        // now starting echo server container mapped to known-as-free host port
        try (
            final GenericContainer echoServer = new FixedHostPortGenericContainer(TEST_IMAGE)
                // using workaround for port bind+expose
                .withFixedExposedPort(unusedHostPort, TEST_PORT)
                .withExposedPorts(TEST_PORT)
                .withCommand("/bin/sh", "-c", HTTP_ECHO_CMD)
        ) {
            echoServer.start();

            assertThat(echoServer.getMappedPort(TEST_PORT))
                .as("Port mapping does not seem to match given fixed port")
                .isEqualTo(unusedHostPort);

            final String content = readResponse(echoServer, unusedHostPort);
            assertThat(content).as("Returned echo from fixed port does not match expected").isEqualTo(TEST_RESPONSE);
        }
    }
*nix pipe to fire test response on test port
core/src/test/java/org/testcontainers/junit/FixedHostPortContainerTest.java