forked from elastic/built-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-started-docker.html
739 lines (705 loc) · 30.8 KB
/
get-started-docker.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>Running the Elastic Stack on Docker | Getting Started [7.9] | Elastic</title>
<meta class="elastic" name="content" content="Running the Elastic Stack on Docker | Getting Started [7.9]">
<link rel="home" href="index.html" title="Getting Started [7.9]"/>
<link rel="up" href="index.html" title="Getting Started [7.9]"/>
<link rel="prev" href="get-started-elastic-stack.html" title="Getting started with the Elastic Stack"/>
<link rel="next" href="get-started-kubernetes.html" title="Running the Elastic Stack on Kubernetes"/>
<meta class="elastic" name="product_version" content="7.9"/>
<meta class="elastic" name="product_name" content="Elastic Stack"/>
<meta class="elastic" name="website_area" content="documentation"/>
<meta name="DC.type" content="Learn/Docs/Elastic Stack/Getting started/7.9"/>
<meta name="DC.subject" content="Elastic Stack"/>
<meta name="DC.identifier" content="7.9"/>
<meta name="robots" content="noindex,nofollow"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdn.optimizely.com/js/18132920325.js"></script>
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/manifest.json">
<meta name="apple-mobile-web-app-title" content="Elastic">
<meta name="application-name" content="Elastic">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/mstile-144x144.png">
<meta name="theme-color" content="#ffffff">
<meta name="naver-site-verification" content="936882c1853b701b3cef3721758d80535413dbfd" />
<meta name="yandex-verification" content="d8a47e95d0972434" />
<meta name="localized" content="true" />
<meta name="st:robots" content="follow,index" />
<meta property="og:image" content="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt280217a63b82a734/6202d3378b1f312528798412/elastic-logo.svg" />
<meta property="og:image:width" content="500" />
<meta property="og:image:height" content="172" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon-precomposed" sizes="64x64" href="/favicon_64x64_16bit.png">
<link rel="apple-touch-icon-precomposed" sizes="32x32" href="/favicon_32x32.png">
<link rel="apple-touch-icon-precomposed" sizes="16x16" href="/favicon_16x16.png">
<!-- Give IE8 a fighting chance -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="/guide/static/styles.css" />
</head>
<!--© 2015-2022 Elasticsearch B.V. -->
<!-- All Elastic documentation is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. -->
<!-- http://creativecommons.org/licenses/by-nc-nd/4.0/ -->
<body>
<!-- Google Tag Manager -->
<script>dataLayer = [];</script><noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-58RLH5" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-58RLH5');</script>
<!-- End Google Tag Manager -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-12395217-16"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-12395217-16');
</script>
<!-- Google Tag Manager for GA4 -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-KNJMG2M');</script>
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KNJMG2M" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager for GA4-->
<div id='elastic-nav' style="display:none;"></div>
<script src='https://www.elastic.co/elastic-nav.js'></script>
<div class="main-container">
<section id="content" >
<div class="content-wrapper">
<section id="guide" lang="en">
<div class="container-fluid">
<div class="row pb-3">
<div class="col-12 order-2 col-md-4 order-md-1 col-lg-3 h-almost-full-md sticky-top-md" id="left_col">
<!-- The TOC is appended here -->
</div>
<div class="col-12 order-1 col-md-8 order-md-2 col-lg-7 order-lg-2 guide-section" id="middle_col">
<!-- start body -->
<div class="page_header">
<strong>IMPORTANT</strong>: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
<a href="../current/index.html">current release documentation</a>.
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="/guide/">Elastic Docs</a></span>
<span class="chevron-right">›</span><span class="breadcrumb-link"><a href="index.html">Getting Started [7.9]</a></span>
</div>
<div class="navheader">
<span class="prev">
<a href="get-started-elastic-stack.html">« Getting started with the Elastic Stack</a>
</span>
<span class="next">
<a href="get-started-kubernetes.html">Running the Elastic Stack on Kubernetes »</a>
</span>
</div>
<div class="chapter">
<div class="titlepage"><div><div>
<h1 class="title"><a id="get-started-docker"></a>Running the Elastic Stack on Docker<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/stack-docs/edit/7.9/docs/en/getting-started/get-started-docker.asciidoc">edit</a></h1>
</div></div></div>
<p>The Elastic Docker registry contains Docker images for all the products in
the Elastic Stack: <a href="https://www.docker.elastic.co/" class="ulink" target="_top">https://www.docker.elastic.co/</a>.</p>
<h3><a id="run-stack-docker"></a>Run with Docker Compose<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/stack-docs/edit/7.9/docs/en/getting-started/get-started-docker.asciidoc">edit</a></h3>
<p>To get the default distributions of Elasticsearch and Kibana up and running in Docker,
you can use Docker Compose.</p>
<div class="olist orderedlist">
<ol class="orderedlist">
<li class="listitem">
<p>Create a <code class="literal">docker-compose.yml</code> file for the Elastic Stack.
The following example brings up a three node cluster and Kibana so you can see how things work.
This all-in-one configuration is a handy way to bring up your first dev cluster before
you build a distributed deployment with multiple hosts.</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">version: '2.2'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
container_name: es01
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es02,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data01:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- elastic
es02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
container_name: es02
environment:
- node.name=es02
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data02:/usr/share/elasticsearch/data
ports:
- 9201:9201
networks:
- elastic
es03:
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
container_name: es03
environment:
- node.name=es03
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es02
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data03:/usr/share/elasticsearch/data
ports:
- 9202:9202
networks:
- elastic
kib01:
image: docker.elastic.co/kibana/kibana:7.9.3
container_name: kib01
ports:
- 5601:5601
environment:
ELASTICSEARCH_URL: http://es01:9200
ELASTICSEARCH_HOSTS: http://es01:9200
networks:
- elastic
volumes:
data01:
driver: local
data02:
driver: local
data03:
driver: local
networks:
elastic:
driver: bridge</pre>
</div>
</li>
<li class="listitem">
Make sure Docker Engine is allotted at least 4GiB of memory.
In Docker Desktop, you configure resource usage on the Advanced tab in Preference (macOS)
or Settings (Windows).
</li>
<li class="listitem">
<p>Run <code class="literal">docker-compose</code> to bring up the three-node Elasticsearch cluster and Kibana:</p>
<div class="pre_wrapper lang-sh">
<pre class="programlisting prettyprint lang-sh">docker-compose up</pre>
</div>
</li>
<li class="listitem">
<p>Submit a <code class="literal">_cat/nodes</code> request to see that the nodes are up and running:</p>
<div class="pre_wrapper lang-sh">
<pre class="programlisting prettyprint lang-sh">curl -X GET "localhost:9200/_cat/nodes?v&pretty"</pre>
</div>
</li>
<li class="listitem">
Open Kibana to load sample data and interact with the cluster:
<a href="http://localhost:5601" class="ulink" target="_top">http://localhost:5601</a>.
</li>
</ol>
</div>
<p>When you’re done experimenting, you can tear down the containers and
volumes by running <code class="literal">docker-compose down -v</code>.</p>
<h3><a id="get-started-docker-tls"></a>Run in Docker with TLS enabled<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/stack-docs/edit/7.9/docs/en/getting-started/get-started-docker.asciidoc">edit</a></h3>
<p>If you have a <a href="/subscriptions" class="ulink" target="_top">Gold (or higher) subscription</a> and the
security features are enabled, you must configure Transport Layer Security
(TLS) encryption for the Elasticsearch transport layer. While it is possible to use a
trial license without setting up TLS, we advise securing your stack from the
start.</p>
<p>To get an Elasticsearch cluster and Kibana up and running in Docker with security enabled,
you can use Docker Compose:</p>
<div class="olist orderedlist">
<ol class="orderedlist">
<li class="listitem">
<p>Create the following compose and configuration files.
These files are also available from the
<a href="https://github.com/elastic/stack-docs/blob/master/docs/en/getting-started/docker/" class="ulink" target="_top">elastic/stack-docs</a>
repository on GitHub.</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<code class="literal">instances.yml</code> identifies the instances you need to create certificates for.
</li>
<li class="listitem">
<code class="literal">.env</code> sets environment variables to specify the Elasticsearch version and
the location where the Elasticsearch certificates will be created.
</li>
<li class="listitem">
<code class="literal">create-certs.yml</code> is a Docker Compose file that launches a container to generate the certificates
for Elasticsearch and Kibana.
</li>
<li class="listitem">
<code class="literal">elastic-docker-tls.yml</code> is a Docker Compose file that brings up a three-node Elasticsearch cluster
and a Kibana instance with TLS enabled so you can see how things work.
This all-in-one configuration is a handy way to bring up your first dev cluster before
you build a distributed deployment with multiple hosts.
</li>
</ul>
</div>
<p><strong><code class="literal">instances.yml</code>:</strong></p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml">instances:
- name: es01
dns:
- es01
- localhost
ip:
- 127.0.0.1
- name: es02
dns:
- es02
- localhost
ip:
- 127.0.0.1
- name: es03
dns:
- es03
- localhost
ip:
- 127.0.0.1
- name: 'kib01'
dns:
- kib01
- localhost</pre>
</div>
<p><strong><code class="literal">.env</code>:</strong></p>
<div class="pre_wrapper lang-txt">
<pre class="programlisting prettyprint lang-txt">COMPOSE_PROJECT_NAME=es
CERTS_DIR=/usr/share/elasticsearch/config/certificates
VERSION=7.9.3</pre>
</div>
<p><strong><code class="literal">create-certs.yml</code>:</strong></p>
<div class="pre_wrapper lang-txt">
<pre class="programlisting prettyprint lang-txt">version: '2.2'
services:
create_certs:
image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION}
container_name: create_certs
command: >
bash -c '
yum install -y -q -e 0 unzip;
if [[ ! -f /certs/bundle.zip ]]; then
bin/elasticsearch-certutil cert --silent --pem --in config/certificates/instances.yml -out /certs/bundle.zip;
unzip /certs/bundle.zip -d /certs;
fi;
chown -R 1000:0 /certs
'
working_dir: /usr/share/elasticsearch
volumes:
- certs:/certs
- .:/usr/share/elasticsearch/config/certificates
networks:
- elastic
volumes:
certs:
driver: local
networks:
elastic:
driver: bridge</pre>
</div>
<p><strong><code class="literal">elastic-docker-tls.yml</code>:</strong></p>
<div class="pre_wrapper lang-txt">
<pre class="programlisting prettyprint lang-txt">version: '2.2'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION}
container_name: es01
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es02,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- xpack.license.self_generated.type=trial <a id="CO1-1"></a><i class="conum" data-value="1"></i>
- xpack.security.enabled=true
- xpack.security.http.ssl.enabled=true <a id="CO1-2"></a><i class="conum" data-value="2"></i>
- xpack.security.http.ssl.key=$CERTS_DIR/es01/es01.key
- xpack.security.http.ssl.certificate_authorities=$CERTS_DIR/ca/ca.crt
- xpack.security.http.ssl.certificate=$CERTS_DIR/es01/es01.crt
- xpack.security.transport.ssl.enabled=true <a id="CO1-3"></a><i class="conum" data-value="3"></i>
- xpack.security.transport.ssl.verification_mode=certificate <a id="CO1-4"></a><i class="conum" data-value="4"></i>
- xpack.security.transport.ssl.certificate_authorities=$CERTS_DIR/ca/ca.crt
- xpack.security.transport.ssl.certificate=$CERTS_DIR/es01/es01.crt
- xpack.security.transport.ssl.key=$CERTS_DIR/es01/es01.key
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data01:/usr/share/elasticsearch/data
- certs:$CERTS_DIR
ports:
- 9200:9200
networks:
- elastic
healthcheck:
test: curl --cacert $CERTS_DIR/ca/ca.crt -s https://localhost:9200 >/dev/null; if [[ $$? == 52 ]]; then echo 0; else echo 1; fi
interval: 30s
timeout: 10s
retries: 5
es02:
image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION}
container_name: es02
environment:
- node.name=es02
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- xpack.license.self_generated.type=trial
- xpack.security.enabled=true
- xpack.security.http.ssl.enabled=true
- xpack.security.http.ssl.key=$CERTS_DIR/es02/es02.key
- xpack.security.http.ssl.certificate_authorities=$CERTS_DIR/ca/ca.crt
- xpack.security.http.ssl.certificate=$CERTS_DIR/es02/es02.crt
- xpack.security.transport.ssl.enabled=true
- xpack.security.transport.ssl.verification_mode=certificate
- xpack.security.transport.ssl.certificate_authorities=$CERTS_DIR/ca/ca.crt
- xpack.security.transport.ssl.certificate=$CERTS_DIR/es02/es02.crt
- xpack.security.transport.ssl.key=$CERTS_DIR/es02/es02.key
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data02:/usr/share/elasticsearch/data
- certs:$CERTS_DIR
networks:
- elastic
es03:
image: docker.elastic.co/elasticsearch/elasticsearch:${VERSION}
container_name: es03
environment:
- node.name=es03
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es02
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- xpack.license.self_generated.type=trial
- xpack.security.enabled=true
- xpack.security.http.ssl.enabled=true
- xpack.security.http.ssl.key=$CERTS_DIR/es03/es03.key
- xpack.security.http.ssl.certificate_authorities=$CERTS_DIR/ca/ca.crt
- xpack.security.http.ssl.certificate=$CERTS_DIR/es03/es03.crt
- xpack.security.transport.ssl.enabled=true
- xpack.security.transport.ssl.verification_mode=certificate
- xpack.security.transport.ssl.certificate_authorities=$CERTS_DIR/ca/ca.crt
- xpack.security.transport.ssl.certificate=$CERTS_DIR/es03/es03.crt
- xpack.security.transport.ssl.key=$CERTS_DIR/es03/es03.key
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data03:/usr/share/elasticsearch/data
- certs:$CERTS_DIR
networks:
- elastic
kib01:
image: docker.elastic.co/kibana/kibana:${VERSION}
container_name: kib01
depends_on: {"es01": {"condition": "service_healthy"}}
ports:
- 5601:5601
environment:
SERVERNAME: localhost
ELASTICSEARCH_URL: https://es01:9200
ELASTICSEARCH_HOSTS: https://es01:9200
ELASTICSEARCH_USERNAME: kibana_system
ELASTICSEARCH_PASSWORD: CHANGEME
ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES: $CERTS_DIR/ca/ca.crt
SERVER_SSL_ENABLED: "true"
SERVER_SSL_KEY: $CERTS_DIR/kib01/kib01.key
SERVER_SSL_CERTIFICATE: $CERTS_DIR/kib01/kib01.crt
volumes:
- certs:$CERTS_DIR
networks:
- elastic
volumes:
data01:
driver: local
data02:
driver: local
data03:
driver: local
certs:
driver: local
networks:
elastic:
driver: bridge</pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO1-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>Generate and apply a trial license that supports Transport Layer Security.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO1-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>Enable Transport Layer Security to encrypt client communications.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO1-3"><i class="conum" data-value="3"></i></a></p>
</td>
<td align="left" valign="top">
<p>Enable Transport Layer Security to encrypt internode communications.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO1-4"><i class="conum" data-value="4"></i></a></p>
</td>
<td align="left" valign="top">
<p>Allow the use of self-signed certificates by not requiring hostname verification.</p>
</td>
</tr>
</table>
</div>
</li>
<li class="listitem">
Make sure Docker Engine is allotted at least 4GiB of memory.
In Docker Desktop, you configure resource usage on the Advanced tab in Preference (macOS)
or Settings (Windows).
</li>
<li class="listitem">
<p>Generate certificates for Elasticsearch by bringing up the <code class="literal">create-certs</code> container:</p>
<div class="pre_wrapper lang-sh">
<pre class="programlisting prettyprint lang-sh">docker-compose -f create-certs.yml run --rm create_certs</pre>
</div>
</li>
<li class="listitem">
<p>Bring up the three-node Elasticsearch cluster:</p>
<div class="pre_wrapper lang-sh">
<pre class="programlisting prettyprint lang-sh">docker-compose -f elastic-docker-tls.yml up -d</pre>
</div>
<div class="important admon">
<div class="icon"></div>
<div class="admon_content">
<p>At this point, Kibana cannot connect to the Elasticsearch cluster.
You must generate a password for the built-in <code class="literal">kibana_system</code> user, update the <code class="literal">ELASTICSEARCH_PASSWORD</code>
in the compose file, and restart to enable Kibana to communicate with the secured cluster.</p>
</div>
</div>
</li>
<li class="listitem">
<p>Run the <code class="literal">elasticsearch-setup-passwords</code> tool to generate passwords for all built-in users,
including the <code class="literal">kibana_system</code> user. If you don’t use PowerShell on Windows, remove the trailing `\`characters
and join the lines before running this command.</p>
<div class="pre_wrapper lang-sh">
<pre class="programlisting prettyprint lang-sh">docker exec es01 /bin/bash -c "bin/elasticsearch-setup-passwords \
auto --batch --url https://es01:9200"</pre>
</div>
<div class="important admon">
<div class="icon"></div>
<div class="admon_content">
<p>Make a note of the generated passwords.
You must configure the <code class="literal">kibana_system</code> user password in the compose file to enable Kibana to connect to Elasticsearch,
and you’ll need the password for the <code class="literal">elastic</code> superuser to
log in to Kibana and submit requests to Elasticsearch.</p>
</div>
</div>
</li>
<li class="listitem">
<p>Set <code class="literal">ELASTICSEARCH_PASSWORD</code> in the <code class="literal">elastic-docker-tls.yml</code> compose file to the password
generated for the <code class="literal">kibana_system</code> user.</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml"> kib01:
image: docker.elastic.co/kibana/kibana:${VERSION}
container_name: kib01
depends_on: {"es01": {"condition": "service_healthy"}}
ports:
- 5601:5601
environment:
SERVERNAME: localhost
ELASTICSEARCH_URL: https://es01:9200
ELASTICSEARCH_HOSTS: https://es01:9200
ELASTICSEARCH_USERNAME: kibana_system
<span class="strong strong"><strong>ELASTICSEARCH_PASSWORD: CHANGEME</strong></span>
ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES: $CERTS_DIR/ca/ca.crt
SERVER_SSL_ENABLED: "true"
SERVER_SSL_KEY: $CERTS_DIR/kib01/kib01.key
SERVER_SSL_CERTIFICATE: $CERTS_DIR/kib01/kib01.crt
volumes:
- certs:$CERTS_DIR
networks:
- elastic</pre>
</div>
</li>
<li class="listitem">
<p>Use <code class="literal">docker-compose</code> to restart the cluster and Kibana:</p>
<div class="pre_wrapper lang-sh">
<pre class="programlisting prettyprint lang-sh">docker-compose stop
docker-compose -f elastic-docker-tls.yml up -d</pre>
</div>
</li>
<li class="listitem">
<p>Open Kibana to load sample data and interact with the cluster:
<a href="https://localhost:5601" class="ulink" target="_top">https://localhost:5601</a>.</p>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>Because SSL is also enabled for communications between Kibana and client browsers,
you must access Kibana via the HTTPS protocol.</p>
</div>
</div>
</li>
</ol>
</div>
<p>When you’re done experimenting, you can tear down the containers, network, and
volumes by running <code class="literal">docker-compose -f elastic-docker-tls.yml down -v</code>.</p>
<h4><a id="load-settings-file"></a>Loading settings from a file<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/stack-docs/edit/7.9/docs/en/getting-started/get-started-docker.asciidoc">edit</a></h4>
<p>Specifying settings for Elasticsearch and {Kibana} directly in the compose file is a convenient way to get started,
but loading settings from a file is preferable once you get past the experimental stage.</p>
<p>For example, to use <code class="literal">es01.yml</code> as the configuration file for the <code class="literal">es01</code> Elasticsearch node,
you can create a bind mount in the volumes section.</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml"> volumes:
- data01:/usr/share/elasticsearch/data
- certs:$CERTS_DIR
- ./es01.yml:/usr/share/elasticsearch/config/elasticsearch.yml</pre>
</div>
<p>Similarly, to load Kibana settings from a file, you overwrite <code class="literal">/usr/share/kibana/config/kibana.yml</code>:</p>
<div class="pre_wrapper lang-yaml">
<pre class="programlisting prettyprint lang-yaml"> volumes:
- certs:$CERTS_DIR
- ./kibana.yml:/usr/share/kibana/config/kibana.yml</pre>
</div>
<h3><a id="_product_specific_instructions_for_docker"></a>Product-specific instructions for Docker<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/stack-docs/edit/7.9/docs/en/getting-started/get-started-docker.asciidoc">edit</a></h3>
<p>See the product-specific documentation for information about running a specific Elastic product in Docker:</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<a href="/guide/en/elasticsearch/reference/7.9/docker.html" class="ulink" target="_top">Install Elasticsearch with Docker</a>
</li>
<li class="listitem">
<a href="/guide/en/apm/server/7.9/running-on-docker.html" class="ulink" target="_top">Running APM Server on Docker</a>
</li>
<li class="listitem">
<a href="/guide/en/beats/auditbeat/7.9/running-on-docker.html" class="ulink" target="_top">Running Auditbeat on Docker</a>
</li>
<li class="listitem">
<a href="/guide/en/beats/filebeat/7.9/running-on-docker.html" class="ulink" target="_top">Running Filebeat on Docker</a>
</li>
<li class="listitem">
<a href="/guide/en/beats/heartbeat/7.9/running-on-docker.html" class="ulink" target="_top">Running Heartbeat on Docker</a>
</li>
<li class="listitem">
<a href="/guide/en/kibana/7.9/docker.html" class="ulink" target="_top">Running Kibana on Docker</a>
</li>
<li class="listitem">
<a href="/guide/en/logstash/7.9/docker.html" class="ulink" target="_top">Running Logstash on Docker</a>
</li>
<li class="listitem">
<a href="/guide/en/beats/metricbeat/7.9/running-on-docker.html" class="ulink" target="_top">Running Metricbeat on Docker</a>
</li>
<li class="listitem">
<a href="/guide/en/beats/packetbeat/7.9/running-on-docker.html" class="ulink" target="_top">Running Packetbeat on Docker</a>
</li>
</ul>
</div>
</div>
<div class="navfooter">
<span class="prev">
<a href="get-started-elastic-stack.html">« Getting started with the Elastic Stack</a>
</span>
<span class="next">
<a href="get-started-kubernetes.html">Running the Elastic Stack on Kubernetes »</a>
</span>
</div>
</div>
<!-- end body -->
</div>
<div class="col-12 order-3 col-lg-2 order-lg-3 h-almost-full-lg sticky-top-lg" id="right_col">
<div id="sticky_content">
<!-- The OTP is appended here -->
<div class="row">
<div class="col-0 col-md-4 col-lg-0" id="bottom_left_col"></div>
<div class="col-12 col-md-8 col-lg-12">
<div id="rtpcontainer">
<div class="mktg-promo" id="most-popular">
<p class="aside-heading">Most Popular</p>
<div class="pb-2">
<p class="media-type">Video</p>
<a href="https://www.elastic.co/webinars/getting-started-elasticsearch?baymax=default&elektra=docs&storm=top-video">
<p class="mb-0">Get Started with Elasticsearch</p>
</a>
</div>
<div class="pb-2">
<p class="media-type">Video</p>
<a href="https://www.elastic.co/webinars/getting-started-kibana?baymax=default&elektra=docs&storm=top-video">
<p class="mb-0">Intro to Kibana</p>
</a>
</div>
<div class="pb-2">
<p class="media-type">Video</p>
<a href="https://www.elastic.co/webinars/introduction-elk-stack?baymax=default&elektra=docs&storm=top-video">
<p class="mb-0">ELK for Logs & Metrics</p>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<div id='elastic-footer'></div>
<script src='https://www.elastic.co/elastic-footer.js'></script>
<!-- Footer Section end-->
</section>
</div>
<script src="/guide/static/jquery.js"></script>
<script type="text/javascript" src="/guide/static/docs.js"></script>
<script type="text/javascript">
window.initial_state = {}</script>
</body>
</html>