@Test
    @Ignore //TODO investigate intermittent failures
    public void failFastWhenContainerHaltsImmediately() {
        long startingTimeNano = System.nanoTime();
        final GenericContainer failsImmediately = new GenericContainer<>(TestImages.ALPINE_IMAGE)
            .withCommand("/bin/sh", "-c", "return false")
            .withMinimumRunningDuration(Duration.ofMillis(100));

        try {
            assertThat(catchThrowable(failsImmediately::start))
                .as("When we start a container that halts immediately, an exception is thrown")
                .isInstanceOf(RetryCountExceededException.class);

            // Check how long it took, to verify that we ARE bailing out early.
            // Want to strike a balance here; too short and this test will fail intermittently
            // on slow systems and/or due to GC variation, too long, and we won't properly test
            // what we're intending to test.
            int allowedSecondsToFailure = GenericContainer.CONTAINER_RUNNING_TIMEOUT_SEC / 2;
            long completedTimeNano = System.nanoTime();
            assertThat(completedTimeNano - startingTimeNano < TimeUnit.SECONDS.toNanos(allowedSecondsToFailure))
                .as("container should not take long to start up")
                .isTrue();
        } finally {
            failsImmediately.stop();
        }
    }
Create a container with an extra host entry and expose the content of /etc/hosts for testing.
core/src/test/java/org/testcontainers/junit/GenericContainerRuleTest.java