public ElasticsearchContainer withPassword(String password) {
        if (isOss) {
            throw new IllegalArgumentException(
                "You can not activate security on Elastic OSS Image. Please switch to the default distribution"
            );
        }
        withEnv("ELASTIC_PASSWORD", password);
        if (!isAtLeastMajorVersion8) {
            // major version 8 is secure by default and does not need this to enable authentication
            withEnv("xpack.security.enabled", "true");
        }
        return this;
    }
Define the Elasticsearch password to set. It enables security behind the scene for major version below 8.0.0.
It's not possible to use security with the oss image.
@param password Password to set
@return this
modules/elasticsearch/src/main/java/org/testcontainers/elasticsearch/ElasticsearchContainer.java