# How to set elasticsearch user "elastic" password in Dockerfile

**URL:** <https://discuss.elastic.co/t/how-to-set-elasticsearch-user-elastic-password-in-dockerfile/226206>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [April 2, 2020, 11:56am UTC](https://discuss.elastic.co/t/how-to-set-elasticsearch-user-elastic-password-in-dockerfile/226206 "2020-04-02T11:56:35Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 2, 2020, 12:53pm UTC](https://discuss.elastic.co/t/how-to-set-elasticsearch-user-elastic-password-in-dockerfile/226206/2 "2020-04-02T12:53:22Z")

</div>

Here is how I'm setting that with docker compose ( `docker-compose.yml`):

```auto
---
version: '3'
services:

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:$ELASTIC_VERSION
    environment:
      - bootstrap.memory_lock=true
      - discovery.type=single-node
      - "ES_JAVA_OPTS=-Xms2g -Xmx2g"
      - ELASTIC_PASSWORD=$ELASTIC_PASSWORD
      - xpack.security.enabled=$ELASTIC_SECURITY
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9200:9200
    networks: ['stack']

  kibana:
    image: docker.elastic.co/kibana/kibana:$ELASTIC_VERSION
    environment:
      - ELASTICSEARCH_USERNAME=elastic
      - ELASTICSEARCH_PASSWORD=$ELASTIC_PASSWORD
    ports: ['5601:5601']
    networks: ['stack']
    links: ['elasticsearch']
    depends_on: ['elasticsearch']

networks:
  stack: {}

```

`.env` file is:

```auto
ELASTIC_VERSION=7.6.2
ELASTIC_SECURITY=true
ELASTIC_PASSWORD=changeme

```

---

_[View the full topic](https://discuss.elastic.co/t/how-to-set-elasticsearch-user-elastic-password-in-dockerfile/226206)._
