How to use elasticsearch-setup-passwords with TLS and selfsigned certificates?

That is correct.

For docker we have a special custom entry point that converts all the environment variables into -E options to Elasticsearch.
That is a special property of the docker image and intentionally isn't used by our general scripts.

Your options to get this working are either:

  1. Pass the relevant settings as -E options to elasticsearch-setup-passwords
  2. Clone the above part of the docker-entrypoint script and then put it into a wrapper around elasticsearch-setup-passwords so it automatically pulls in the relevant environment variables.

With pure docker we've generally expected that people won't need to run scripts in the container that have this environment reading magic, but that assumption seems to be less true these days, so we may need to look at something that can replicate that behaviour in our other utilities.