# Issue generating token after adding PV

**URL:** <https://discuss.elastic.co/t/issue-generating-token-after-adding-pv/319537>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [November 22, 2022, 10:18am UTC](https://discuss.elastic.co/t/issue-generating-token-after-adding-pv/319537 "2022-11-22T10:18:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lkurczy](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@lkurczy](https://discuss.elastic.co/u/lkurczy)\
**Post date:** [November 22, 2022, 10:18am UTC](https://discuss.elastic.co/t/issue-generating-token-after-adding-pv/319537/1 "2022-11-22T10:18:05Z")

</div>

Hello,  
Im trying to configure a new instance of elasticsearch and kibana in docker.  
When i run it with the following commands, everything runs smoothly and im able to run kibana with security enabled:

`docker run --name elastic --restart unless-stopped --net elk -d -p 9200:9200 -p 9300:9300 -e discovery.type=single-node -e ES_JAVA_OPTS="-Xms2g -Xmx4g" -e ELASTIC_PASSWORD=<PW> -it docker.elastic.co/elasticsearch/elasticsearch:8.5.0`

`docker run --name kibana --restart unless-stopped --net elk -p 5601:5601 -e SERVER_NAME='elk02t.domain.local' docker.elastic.co/kibana/kibana:8.5.0`

`docker exec -it elastic /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana`

The issue is, that i want to use a Persistent Volume for data. Once i put an option for it, im not able to generate the token, and getting error.  
Command i use:  
`docker run --name elastic --restart unless-stopped --net elk -d -p 9200:9200 -p 9300:9300 -v '/var/lib/docker/esdata:/usr/share/elasticsearch/data' -e discovery.type=single-node -e ES_JAVA_OPTS="-Xms2g -Xmx4g" -e ELASTIC_PASSWORD=<PW> -it docker.elastic.co/elasticsearch/elasticsearch:8.5.0`

`docker exec -it elastic /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana`

Output from generating the token:  
`ERROR: [xpack.security.enrollment.enabled] must be set to `true` to create an enrollment token`

Could you please help me with this issue? Im able to generate the token, but once a use a Persistent volume for data, it says that the option needs to set to true.  
I also tried to add the option xpack.security.enrollment.enabled: true to elasticsearch.yml, but it did not fix my issue,  
thank you

---

<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:** [December 20, 2022, 10:18am UTC](https://discuss.elastic.co/t/issue-generating-token-after-adding-pv/319537/2 "2022-12-20T10:18:25Z")

</div>

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