private BufferedReader getReaderForContainerPort80(GenericContainer container) {
        return Unreliables.retryUntilSuccess(
            10,
            TimeUnit.SECONDS,
            () -> {
                Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);

                Socket socket = new Socket(container.getHost(), container.getFirstMappedPort());
                return new BufferedReader(new InputStreamReader(socket.getInputStream()));
            }
        );
    }
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