Set elasticsearch initial password via docker-compose

Viewed 816

Can i know, how to set initial password for elasticsearch database using docker-compose

bin/elasticsearch-setup-passwords auto -u "http://192.168.2.120:9200
1 Answers

See this:

The initial password can be set at start up time via the ELASTIC_PASSWORD environment variable:

docker run -e ELASTIC_PASSWORD=MagicWord docker.elastic.co/elasticsearch/elasticsearch-platinum:6.1.4

Also, for newest image (docker.elastic.co/elasticsearch/elasticsearch:7.14.0), the ELASTIC_PASSWORD_FILE environment added mentioned in Configuring Elasticsearch with Docker:

For example, to set the Elasticsearch bootstrap password from a file, you can bind mount the file and set the ELASTIC_PASSWORD_FILE environment variable to the mount location. If you mount the password file to /run/secrets/bootstrapPassword.txt, specify:

-e ELASTIC_PASSWORD_FILE=/run/secrets/bootstrapPassword.txt

So add these environment in docker-compose.yaml I guess could work for you.

Related