Skip to content

Commit a59ab5a

Browse files
Adds Docker configuration for Elasticsearch, Kibana and APM server (#376)
Our recent example-apps all use OpenTelemetry, and have Docker instructions in common. This copies the pertinent parts to a separate directory which can be used by others as needed, without confusion. If at some point start-local adds support for APM Server or EDOT collector, we may be able to remove this and still have a working setup for Elasticsearch, Kibana and OTLP collection. Signed-off-by: Adrian Cole <[email protected]>
1 parent 2ec6384 commit a59ab5a

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed

docker/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Running your own Elastic Stack with Docker
2+
3+
If you'd like to start Elastic locally, you can use the provided
4+
[docker-compose-elastic.yml](docker-compose-elastic.yml) file. This starts
5+
Elasticsearch, Kibana, and APM Server and only requires Docker installed.
6+
7+
Note: If you haven't checked out this repository, all you need is one file:
8+
```bash
9+
wget https://raw.githubusercontent.com/elastic/elasticsearch-labs/refs/heads/main/docker/docker-compose-elastic.yml
10+
```
11+
12+
Use docker compose to run Elastic stack in the background:
13+
14+
```bash
15+
docker compose -f docker-compose-elastic.yml up --force-recreate -d
16+
```
17+
18+
Then, you can view Kibana at http://localhost:5601/app/home#/
19+
20+
If asked for a username and password, use username: elastic and password: elastic.
21+
22+
Clean up when finished, like this:
23+
24+
```bash
25+
docker compose -f docker-compose-elastic.yml down
26+
```

docker/docker-compose-elastic.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: elastic-stack
2+
3+
services:
4+
elasticsearch:
5+
image: docker.elastic.co/elasticsearch/elasticsearch:8.17.0
6+
container_name: elasticsearch
7+
ports:
8+
- 9200:9200
9+
environment:
10+
- node.name=elasticsearch
11+
- cluster.name=docker-cluster
12+
- discovery.type=single-node
13+
- ELASTIC_PASSWORD=elastic
14+
- bootstrap.memory_lock=true
15+
- xpack.security.enabled=true
16+
- xpack.security.http.ssl.enabled=false
17+
- xpack.security.transport.ssl.enabled=false
18+
- xpack.license.self_generated.type=trial
19+
- ES_JAVA_OPTS=-Xmx8g
20+
ulimits:
21+
memlock:
22+
soft: -1
23+
hard: -1
24+
healthcheck:
25+
test: ["CMD-SHELL", "curl -s http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=500ms"]
26+
retries: 300
27+
interval: 1s
28+
29+
elasticsearch_settings:
30+
depends_on:
31+
elasticsearch:
32+
condition: service_healthy
33+
image: docker.elastic.co/elasticsearch/elasticsearch:8.17.0
34+
container_name: elasticsearch_settings
35+
restart: 'no'
36+
command: >
37+
bash -c '
38+
# gen-ai assistants in kibana save state in a way that requires security to be enabled, so we need to create
39+
# a kibana system user before starting it.
40+
echo "Setup the kibana_system password";
41+
until curl -s -u "elastic:elastic" -X POST http://elasticsearch:9200/_security/user/kibana_system/_password -d "{\"password\":\"elastic\"}" -H "Content-Type: application/json" | grep -q "^{}"; do sleep 5; done;
42+
'
43+
44+
kibana:
45+
image: docker.elastic.co/kibana/kibana:8.17.0
46+
container_name: kibana
47+
depends_on:
48+
elasticsearch_settings:
49+
condition: service_completed_successfully
50+
ports:
51+
- 5601:5601
52+
environment:
53+
- SERVERNAME=kibana
54+
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
55+
- ELASTICSEARCH_USERNAME=kibana_system
56+
- ELASTICSEARCH_PASSWORD=elastic
57+
# Non-default settings from here:
58+
# https://github.com/elastic/apm-server/blob/main/testing/docker/kibana/kibana.yml
59+
- MONITORING_UI_CONTAINER_ELASTICSEARCH_ENABLED=true
60+
- XPACK_SECURITY_ENCRYPTIONKEY=fhjskloppd678ehkdfdlliverpoolfcr
61+
- XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY=fhjskloppd678ehkdfdlliverpoolfcr
62+
- SERVER_PUBLICBASEURL=http://127.0.0.1:5601
63+
healthcheck:
64+
test: ["CMD-SHELL", "curl -s http://localhost:5601/api/status | grep -q 'All services are available'"]
65+
retries: 300
66+
interval: 1s
67+
68+
apm-server:
69+
image: docker.elastic.co/apm/apm-server:8.17.0
70+
container_name: apm-server
71+
depends_on:
72+
elasticsearch:
73+
condition: service_healthy
74+
command: >
75+
apm-server
76+
-E apm-server.kibana.enabled=true
77+
-E apm-server.kibana.host=http://kibana:5601
78+
-E apm-server.kibana.username=elastic
79+
-E apm-server.kibana.password=elastic
80+
-E output.elasticsearch.hosts=["http://elasticsearch:9200"]
81+
-E output.elasticsearch.username=elastic
82+
-E output.elasticsearch.password=elastic
83+
cap_add: ["CHOWN", "DAC_OVERRIDE", "SETGID", "SETUID"]
84+
cap_drop: ["ALL"]
85+
ports:
86+
- 8200:8200
87+
healthcheck:
88+
test: ["CMD-SHELL", "bash -c 'echo -n > /dev/tcp/127.0.0.1/8200'"]
89+
retries: 300
90+
interval: 1s
91+

0 commit comments

Comments
 (0)