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

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. 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), which would look like this in kibana.yml:

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:

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

I get this error:

 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

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.

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

You can find more examples of supported environment variables here:

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) 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.

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