@Test
    public void testElasticsearchCustomMaxHeapSizeInJvmOptionsFile() throws Exception {
        long customHeapSize = 1574961152;

        try (
            ElasticsearchContainer container = new ElasticsearchContainer(ELASTICSEARCH_IMAGE)
                .withClasspathResourceMapping(
                    "test-custom-memory-jvm.options",
                    "/usr/share/elasticsearch/config/jvm.options.d/a-user-defined-jvm.options",
                    BindMode.READ_ONLY
                );
        ) {
            container.start();
            assertElasticsearchContainerHasHeapSize(container, customHeapSize);
        }
    }
From 6.8, we can optionally activate security with a default password.
modules/elasticsearch/src/test/java/org/testcontainers/elasticsearch/ElasticsearchContainerTest.java