@Test
    public void createContainerCmdHookTest() {
        // Use random name to avoid the conflicts between the tests
        String randomName = Base58.randomString(5);
        try (
            GenericContainer<?> container = new GenericContainer<>(TestImages.REDIS_IMAGE)
                .withCommand("redis-server", "--help")
                .withCreateContainerCmdModifier(cmd -> cmd.withName("overrideMe"))
                // Preserves the order
                .withCreateContainerCmdModifier(cmd -> cmd.withName(randomName))
                // Allows to override pre-configured values by GenericContainer
                .withCreateContainerCmdModifier(cmd -> cmd.withCmd("redis-server", "--port", "6379"))
        ) {
            container.start();

            assertThat(container.getContainerInfo().getName()).as("Name is configured").isEqualTo("/" + randomName);
            assertThat(Arrays.toString(container.getContainerInfo().getConfig().getCmd()))
                .as("Command is configured")
                .isEqualTo("[redis-server, --port, 6379]");
        }
    }
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