Why isn't my ELASTIC_PASSWORD environment variable in docker-compose.yml setting?

Hello,
I'm currently testing out elastic-search on docker. I'm trying to change the default password for the elastic user.

I have the following entry in my docker-compose file:

  po-esearch:
    container_name: "po-esearch"
    restart: unless-stopped
    image:
      docker.elastic.co/elasticsearch/elasticsearch:5.6.3
    ports:
      - "9200:9200"
      - "9300:9300"
    networks:
      - "po-logging-net"
    volumes:
      - ./esearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - ./esearch/log4j2.properties:/usr/share/elasticsearch/config/log4j2.properties
    environment:
      - ELASTIC_PASSWORD=XXXXX

However, when i test the health API using basic auth i get the following:

{
    "error": {
        "root_cause": [
            {
                "type": "security_exception",
                "reason": "failed to authenticate user [elastic]",
                "header": {
                    "WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
                }
            }
        ],
        "type": "security_exception",
        "reason": "failed to authenticate user [elastic]",
        "header": {
            "WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
        }
    },
    "status": 401
}

Setting the password from XXXXX to changeme results in a 200 response.

what are best practices to pass in my private password?

See:

See:

The ELASTIC_PASSWORD environment variable is used in our docker images for the upcoming 6.0 release of Elasticsearch.

Since you are using 5.6.3, there is no support for changing the password via an environment variable, you need to wait for the server to start and then change the password via the API.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.