# How to use keystore in Dockerized logstash?

**URL:** <https://discuss.elastic.co/t/how-to-use-keystore-in-dockerized-logstash/199694>\
**Category:** Logstash\
**Tags:** docker\
**Created:** [September 16, 2019, 3:51pm UTC](https://discuss.elastic.co/t/how-to-use-keystore-in-dockerized-logstash/199694 "2019-09-16T15:51:34Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![furiabhavesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/furiabhavesh/32/52498_2.png) [@furiabhavesh](https://discuss.elastic.co/u/furiabhavesh)\
**Post date:** [October 13, 2019, 6:35am UTC](https://discuss.elastic.co/t/how-to-use-keystore-in-dockerized-logstash/199694/3 "2019-10-13T06:35:07Z")

</div>

Yes, I had to add my keystore file in docker image so that I can access those credentials in the container.

```auto
FROM docker.elastic.co/logstash/logstash:7.3.2

RUN rm -f /usr/share/logstash/pipeline/logstash.conf

ADD logstash.yml /usr/share/logstash/config/logstash.yml
ADD logstash.conf /usr/share/logstash/pipeline/logstash.conf
ADD logstash.keystore /usr/share/logstash/config/logstash.keystore 

```

Which also means, I had to rebuild the image every time there was a change in keystore.

I was confused about defining **every key** in keystore if that needs to be accessible as environment variable, but after [discussing it from here](https://github.com/elastic/logstash/issues/9007#issuecomment-540686940) I realized that it's not the case.

> I can access any environment variable passed in .conf file, even if that's not declared in keystore file. Declaring every environment variable in keystore is not mandatory.

[It also helped me to understand that:](https://github.com/elastic/logstash/issues/9007#issuecomment-540814069)

> If the variable exists in the keystore, the value from the keystore is **always** used; only if it is _missing_ from the keystore is it sourced from the environment.

---

_[View the full topic](https://discuss.elastic.co/t/how-to-use-keystore-in-dockerized-logstash/199694)._
