# Why isn't my ELASTIC\_PASSWORD environment variable in docker-compose.yml setting?

**URL:** <https://discuss.elastic.co/t/why-isnt-my-elastic-password-environment-variable-in-docker-compose-yml-setting/105299>\
**Category:** Elasticsearch\
**Created:** [October 25, 2017, 8:53pm UTC](https://discuss.elastic.co/t/why-isnt-my-elastic-password-environment-variable-in-docker-compose-yml-setting/105299 "2017-10-25T20:53:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jack\_Murphy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_murphy/32/23414_2.png) [@Jack\_Murphy](https://discuss.elastic.co/u/Jack_Murphy)\
**Post date:** [October 25, 2017, 8:53pm UTC](https://discuss.elastic.co/t/why-isnt-my-elastic-password-environment-variable-in-docker-compose-yml-setting/105299/1 "2017-10-25T20:53:13Z")

</div>

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:

> <https://github.com/elastic/elasticsearch-docker/blob/0abc1f8ca2e43062646e733d3c3d920f719a1aa7/templates/docker-compose-fragment.yml.j2>

See:

> <https://github.com/elastic/elasticsearch-docker/blob/1d80b20ef8a7ab9ebf4e711519f4894c7747133b/build/elasticsearch/bin/docker-entrypoint.sh>

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [October 27, 2017, 7:05am UTC](https://discuss.elastic.co/t/why-isnt-my-elastic-password-environment-variable-in-docker-compose-yml-setting/105299/2 "2017-10-27T07:05:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 24, 2017, 7:05am UTC](https://discuss.elastic.co/t/why-isnt-my-elastic-password-environment-variable-in-docker-compose-yml-setting/105299/3 "2017-11-24T07:05:05Z")

</div>

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