How to setup a basic authentication for Elasticsearch?

I think you need to use ELASTIC_PASSWORD instead.
I shared an example (docker-compose) here: Create user in elasticsearch