# Change x-pack password in docker container at initialisation

**URL:** <https://discuss.elastic.co/t/change-x-pack-password-in-docker-container-at-initialisation/82736>\
**Category:** Elasticsearch\
**Created:** [April 18, 2017, 2:26pm UTC](https://discuss.elastic.co/t/change-x-pack-password-in-docker-container-at-initialisation/82736 "2017-04-18T14:26:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rgn](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@Rgn](https://discuss.elastic.co/u/Rgn)\
**Post date:** [April 18, 2017, 2:26pm UTC](https://discuss.elastic.co/t/change-x-pack-password-in-docker-container-at-initialisation/82736/1 "2017-04-18T14:26:59Z")

</div>

Hi

I'm new with docker and elastic, i would like to change the default password for x-pack user at the building of my image. I tried to use curl inside a dockfile but without succes :

```
FROM docker.elastic.co/elasticsearch/elasticsearch:5.3.0

ADD ./config/elasticsearch.yml /usr/share/elasticsearch/config/
USER root
RUN chown elasticsearch:elasticsearch config/elasticsearch.yml
USER elasticsearch

CMD curl -XPUT -m 5 -u elastic:changeme 'http://my_ip:9200/_xpack/security/user/elastic/_password' -H "Content-Type: application/json" -d '{ "password" : "myNewPwd" }

```

but the curl will never work because the instance of elasticsearch is not up when docker execute that command .  
Any idea of how to do what i want ? :

- run contenair of [docker.elastic.co/elasticsearch/elasticsearch:5.3.0](http://docker.elastic.co/elasticsearch/elasticsearch:5.3.0)
- when is up exec my curl to change the default password.

Thanx by advance

---

<div class="post-metadata">

**Author:** ![pablosan](https://avatars.discourse-cdn.com/v4/letter/p/e19adc/32.png) [@pablosan](https://discuss.elastic.co/u/pablosan)\
**Post date:** [April 20, 2017, 8:12am UTC](https://discuss.elastic.co/t/change-x-pack-password-in-docker-container-at-initialisation/82736/2 "2017-04-20T08:12:49Z")

</div>

is enabling anonymous access an option?  
I don't think you can change the password without running Elasticsearch

---

<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:** [May 18, 2017, 8:23am UTC](https://discuss.elastic.co/t/change-x-pack-password-in-docker-container-at-initialisation/82736/3 "2017-05-18T08:23:13Z")

</div>

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