# Supplying a config object using an environment variable (especially for anonymous authentication using Docker)

**URL:** <https://discuss.elastic.co/t/supplying-a-config-object-using-an-environment-variable-especially-for-anonymous-authentication-using-docker/314413>\
**Category:** Kibana\
**Tags:** elastic-stack-security, docker\
**Created:** [September 14, 2022, 12:56pm UTC](https://discuss.elastic.co/t/supplying-a-config-object-using-an-environment-variable-especially-for-anonymous-authentication-using-docker/314413 "2022-09-14T12:56:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonasjancarik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonasjancarik/32/87174_2.png) [@jonasjancarik](https://discuss.elastic.co/u/jonasjancarik)\
**Post date:** [September 14, 2022, 12:56pm UTC](https://discuss.elastic.co/t/supplying-a-config-object-using-an-environment-variable-especially-for-anonymous-authentication-using-docker/314413/1 "2022-09-14T12:56:34Z")

</div>

I know it is possible to submit an array in an environment variable, as described in [Install Kibana with Docker | Kibana Guide [8.4] | Elastic](https://www.elastic.co/guide/en/kibana/current/docker.html#environment-variable-config). I can't, however, figure out how to submit the configuration needed to set up anonymous authentication ([Authentication in Kibana | Kibana Guide [8.4] | Elastic](https://www.elastic.co/guide/en/kibana/8.4/kibana-authentication.html#anonymous-authentication)), which would look like this in `kibana.yml`:

```auto
xpack.security.authc.providers:
  anonymous.anonymous1:
    order: 0
    credentials:
      username: "anonymous_service_account"
      password: "anonymous_service_account_password"

```

When I try to supply a JSON like this in `docker-compose.yml`:

```auto
      XPACK_SECURITY_AUTHC_PROVIDERS: >
        [{"anonymous.anonymous1": { "order": 0, "credentials": { "username": "kibana_system", "password": "${KIBANA_SYSTEM_PASSWORD}" }}}]

```

I get this error:

```auto
 FATAL Error: [config validation of [xpack.security].authc.providers]: types that failed validation:
- [config validation of [xpack.security].authc.providers.0]: could not parse array value from json input
- [config validation of [xpack.security].authc.providers.1]: could not parse object value from json input

```

---

<div class="post-metadata">

**Author:** ![Justin\_Cranford](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_cranford/32/85302_2.png) [@Justin\_Cranford](https://discuss.elastic.co/u/Justin_Cranford)\
**Post date:** [September 14, 2022, 1:22pm UTC](https://discuss.elastic.co/t/supplying-a-config-object-using-an-environment-variable-especially-for-anonymous-authentication-using-docker/314413/2 "2022-09-14T13:22:25Z")

</div>

Can you try passing config parameters as multiple environment variables? They can be specified with flat name instead of nested JSON. Here is an example with two config settings.

```auto
docker run --name elastic1 -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "bootstrap.memory_lock=true" --rm -d docker.elastic.co/elasticsearch/elasticsearch:8.4.1
docker stop elastic1

```

---

<div class="post-metadata">

**Author:** ![Justin\_Cranford](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_cranford/32/85302_2.png) [@Justin\_Cranford](https://discuss.elastic.co/u/Justin_Cranford)\
**Post date:** [September 14, 2022, 1:26pm UTC](https://discuss.elastic.co/t/supplying-a-config-object-using-an-environment-variable-especially-for-anonymous-authentication-using-docker/314413/3 "2022-09-14T13:26:02Z")

</div>

You can find more examples of supported environment variables here:

> **[Install Elasticsearch with Docker | Elasticsearch Guide \[8.4\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#_windows_with_docker_desktop_wsl_2_backend)**

---

<div class="post-metadata">

**Author:** ![jonasjancarik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonasjancarik/32/87174_2.png) [@jonasjancarik](https://discuss.elastic.co/u/jonasjancarik)\
**Post date:** [September 14, 2022, 6:12pm UTC](https://discuss.elastic.co/t/supplying-a-config-object-using-an-environment-variable-especially-for-anonymous-authentication-using-docker/314413/4 "2022-09-14T18:12:21Z")

</div>

That looks like it could work for Elasticearch, but isn't that different for Kibana? The docs for Kibana ([Install Kibana with Docker | Kibana Guide [8.4] | Elastic](https://www.elastic.co/guide/en/kibana/current/docker.html#environment-variable-config)) mention supplying arrays specifically, so I was wondering how to translate the YAML structure to an env var so that my Docker deployment wouldn't have to rely on a mounted `kibana.yml` file.

---

<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:** [October 12, 2022, 6:12pm UTC](https://discuss.elastic.co/t/supplying-a-config-object-using-an-environment-variable-especially-for-anonymous-authentication-using-docker/314413/5 "2022-10-12T18:12:45Z")

</div>

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