# Fleet preconfiguration in docker without kibana.yml

**URL:** <https://discuss.elastic.co/t/fleet-preconfiguration-in-docker-without-kibana-yml/310126>\
**Category:** Elastic Agent\
**Created:** [July 20, 2022, 9:53am UTC](https://discuss.elastic.co/t/fleet-preconfiguration-in-docker-without-kibana-yml/310126 "2022-07-20T09:53:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lineconnect](https://avatars.discourse-cdn.com/v4/letter/l/ecae2f/32.png) [@lineconnect](https://discuss.elastic.co/u/lineconnect)\
**Post date:** [July 20, 2022, 9:53am UTC](https://discuss.elastic.co/t/fleet-preconfiguration-in-docker-without-kibana-yml/310126/1 "2022-07-20T09:53:03Z")

</div>

Hi there,

we're using beets for a while now and want to migrate to elasit\_agent and fleet.  
Our complete setup is in k8s, will created and maintained with terraform and init-containers which are configuring elastic and kibana.

So we're using your docker images and using [env vars](https://www.elastic.co/guide/en/kibana/7.17/docker.html#environment-variable-config) because it's very helpful to not have a configuration file for every service.

Everyting else is done by speaking with the API.

I'm stuck by creating/preconfiguring the agent policies.  
There is the Fleet API where you can create a agent policy you havn't the option to define the id for. And because for assigning packages to agent\_policies the ID is needed(or is there a way by referencing the agent policy name?? havn't found it).

But when preconfiguring the fleet settings by the [kibana.yml](https://www.elastic.co/guide/en/fleet/current/create-a-policy-no-ui.html#use-preconfiguration-to-create-policy), you have the option to define a custom id.

The problem is that i can't find a way of passing the yml configuration trough docker environment vars.  
I've played around with the XPACK\_FLEET settings a bit and came to a point where a error message of kibana was something like "can't parse json array". So i thougt it may a option to pass the value as json, but that results in the error:

```auto
Configuring logger failed: TypeError: Cannot read properties of undefined (reading 'length')

```

Is there either a way of set a agent\_policy with a custom id trough the API or to let kibana preconfigure Fleet by using the env vars?

My sample compose:

```auto
version: '3.7'
services:
  kibana:
    image: docker.elastic.co/kibana/kibana:7.16.2
    container_name: testkibana
    ports:
      - 127.0.0.1:5601:5601
    environment:
      - ELASTICSEARCH_URL=http://elasticsearch:9200
      - ELASTICSEARCH_USERNAME=kibana_system
      - ELASTICSEARCH_PASSWORD=..Password56
      - SERVER_NAME=kibana
      - SERVER_BASEPATH=/kibana
      - SERVER_REWRITEBASEPATH=true
      - TELEMETRY_ENABLED=false
      - XPACK_FLEET_AGENTS_ENABLED=true
      - XPACK_FLEET_PACKAGES=[{"name":"fleet_server","version":"latest"}]
      - XPACK_FLEET_AGENTPOLICIES={"name":"Test compose policy","id":"test-compose-policy","namespace":"default","package_policies":[{"name":"fleet_server-1","package":{"name":"fleet_server"}}]}

```

---

<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:** [August 17, 2022, 9:53am UTC](https://discuss.elastic.co/t/fleet-preconfiguration-in-docker-without-kibana-yml/310126/2 "2022-08-17T09:53:20Z")

</div>

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