NOT FOR PRODUCTION USE
Partially based on https://www.elastic.co/docs/deploy-manage/deploy/self-managed/install-elasticsearch-docker-compose
Local two-node Elasticsearch cluster for development, run with Docker Compose. Generates its own CA + node certificates on first start and seeds a few example roles and users via the Security API.
There is no Kibana service in this compose file — the kibana_system password is configured so you can run Kibana in dev mode and point it at this cluster.
docker-compose.yml—setup(CA + cert generation, setskibana_systempassword),es01,es02(HTTP + transport TLS, security enabled).docker-compose.saml.yml— opt-in override that adds a SAML "Mock IdP" realm toes01/es02for local Kibana withmockIdpPluginenabled (see SAML Mock IdP)..env—STACK_VERSION,ELASTIC_PASSWORD,KIBANA_PASSWORD,CLUSTER_NAME,LICENSE(basicortrial),ES_PORT,MEM_LIMIT.create-users.sh— POSTs roles (data_user,dev_reporting_user,discover_read_only) and users (test_user,discover_read_only_user) tohttps://localhost:9200.certs/— generated by thesetupservice on first run; gitignored.saml/metadata.xml,saml/roles.yml— pre-generated IdP metadata and stateful built-in roles, mounted into ES when the SAML override is used.
Start the cluster:
docker compose up -des01 is exposed on https://localhost:${ES_PORT} (default 9200). The CA cert is written to certs/ca/ca.crt; use it (or curl -k) to talk to the cluster:
curl --cacert certs/ca/ca.crt -u elastic:changeme https://localhost:9200Seed example roles and users (cluster must be up):
./create-users.shStop and wipe data:
docker compose down -vTo run local Kibana (yarn start) with the SAML provider that the Mock IdP plugin drives, bring the cluster up with the SAML override:
docker compose -f docker-compose.yml -f docker-compose.saml.yml up -dThis adds a cloud-saml-kibana SAML realm to both ES nodes, mounts a pre-generated saml/metadata.xml (signed with Kibana's dev cert from @kbn/dev-utils) and the stateful built-in roles (viewer, editor, admin, system_indices_superuser) via saml/roles.yml. A saml-setup one-shot container then creates the mock-idp-mapping role mapping that maps the SAML groups attribute to ES roles — this is what kbn-es would normally do when starting ES via yarn es snapshot. Kibana is assumed to be reachable at http://localhost:5601/kbn — that base path comes from MOCK_IDP_KIBANA_BASE_PATH and Kibana auto-applies it when mockIdpPlugin is enabled, so just run:
yarn startRequires LICENSE=trial in .env (SAML is not available on basic). Without -f docker-compose.saml.yml the cluster comes up exactly as before, with no SAML realm — pair that with yarn start --mockIdpPlugin.enabled=false if Kibana would otherwise auto-configure the SAML provider.
If you change the Kibana URL or base path, regenerate saml/metadata.xml and update the sp.entity_id / sp.acs / sp.logout URLs in docker-compose.saml.yml to match.
- Default passwords in
.envarechangeme. Change them before exposing the cluster anywhere non-local. - Bumping
STACK_VERSIONagainst an existingdata01/data02volume can fail —docker compose down -vto start clean. - If cert generation gets into a bad state, delete
certs/and bring the stack back up; thesetupservice will regenerate everything.