How to change default elasticsearch password in docker-compose?
Starting from 6.0 elasticsearch docker images has the ability to configure the password using the following environment variable - ELASTIC_PASSWORD.
For example:
docker run -e ELASTIC_PASSWORD=MagicWord docker.elastic.co/elasticsearch/elasticsearch-platinum:6.1.3
See:
https://www.elastic.co/guide/en/elasticsearch/reference/6.1/docker.html
Related videos on Youtube
Ariel
Python/Django developer, philosophy MA, secular humanist activist, blogger at ghostlessmachine.com.
Updated on November 02, 2022Comments
-
Ariel about 1 year
Elasticsearch's official docker image documentation provides this
docker-compose.yml
example:version: '2' services: elasticsearch1: image: docker.elastic.co/elasticsearch/elasticsearch:5.6.3 container_name: elasticsearch1 environment: - cluster.name=docker-cluster - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 mem_limit: 1g volumes: - esdata1:/usr/share/elasticsearch/data ports: - 9200:9200 networks: - esnet elasticsearch2: image: docker.elastic.co/elasticsearch/elasticsearch:5.6.3 environment: - cluster.name=docker-cluster - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - "discovery.zen.ping.unicast.hosts=elasticsearch1" ulimits: memlock: soft: -1 hard: -1 mem_limit: 1g volumes: - esdata2:/usr/share/elasticsearch/data networks: - esnet volumes: esdata1: driver: local esdata2: driver: local networks: esnet:
However, it doesn't explain how to customize the password. It does direct us to a X-Pack documentation page, but I refuse to believe I have to go through all that trouble just to change a password. Is there any simpler, canonical way of configuring a custom password for elasticsearch on a Docker Compose file?
-
Alexander almost 5 yearsDid they delete it? Because I don't see this variable in the new docs for 6.x? elastic.co/guide/en/elasticsearch/reference/6.x/docker.html
-
hwkd about 3 yearsJust FYI, I've confirmed that setting the env variable ELASTIC_PASSWORD works in elasticsearch:7.9.1
-
stopsopa over 2 yearsIt looks like ELASTIC_PASSWORD variable is supported only in platinum version of the docker image: elastic.co/guide/en/elasticsearch/reference/6.1/…