Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change default elasticsearch password in docker-compose?

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?

like image 306
Ariel Avatar asked Oct 17 '17 10:10

Ariel


People also ask

Where password is the password of the elastic user?

This elastic user has full access to the cluster, including all indices and data, so the elastic user does not have a password set by default.

What is elastic search in docker?

Elasticsearch is a powerful open source search and analytics engine that makes data easy to explore. docker pull elasticsearch. OverviewTags.


1 Answers

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

like image 114
Elad Tamary Avatar answered Oct 04 '22 19:10

Elad Tamary