title: How to change default elasticsearch password in docker-compose?
body: <p>Elasticsearch's <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html" rel="noreferrer">official docker image documentation</a> provides this <code>docker-compose.yml</code> example:</p>
  
  <pre><code>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:
  </code></pre>
  
  <p>However, it doesn't explain how to customize the password. It does direct us to a <a href="https://www.elastic.co/guide/en/x-pack/5.6/security-getting-started.html" rel="noreferrer">X-Pack documentation page</a>, 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?</p>