1
1
[[docker]]
2
2
=== Install {es} with Docker
3
3
4
- {es} is also available as Docker images. A list of all published Docker
5
- images and tags is available at
6
- https://www.docker.elastic.co[www.docker.elastic.co]. The source files are
7
- in
4
+ {es} is available as a Docker image. A list of all published Docker images and
5
+ tags is available at https://www.docker.elastic.co[www.docker.elastic.co]. The
6
+ source files are in
8
7
https://github.com/elastic/elasticsearch/blob/{branch}/distribution/docker[Github].
9
8
10
9
include::license.asciidoc[]
@@ -13,19 +12,19 @@ Starting in {es} 8.0, security is enabled by default. With security enabled,
13
12
{stack} {security-features} require TLS encryption for the transport networking
14
13
layer, or your cluster will fail to start.
15
14
16
- ==== Install Docker Desktop or Docker Engine
15
+ ==== Install Docker
17
16
18
- Install the appropriate https://docs.docker.com/get-docker/[Docker application]
19
- for your operating system .
17
+ Visit https://docs.docker.com/get-docker/[Get Docker] to install Docker for your
18
+ environment .
20
19
21
- NOTE: Make sure that Docker is allotted at least 4GiB of memory. In Docker
22
- Desktop, you configure resource usage on the Advanced tab in Preference (macOS)
23
- or Settings (Windows) .
20
+ IMPORTANT: If using Docker Desktop, make sure to allocate at least 4GB of
21
+ memory. You can adjust memory usage in Docker Desktop by going to **Settings >
22
+ Resources** .
24
23
25
- ==== Pull the {es} Docker image
24
+ ==== Pull the Docker image
26
25
27
- Obtaining {es} for Docker is as simple as issuing a `docker pull` command
28
- against the Elastic Docker registry.
26
+ Use the `docker pull` command to pull the {es} image from the the Elastic Docker
27
+ registry.
29
28
30
29
ifeval::["{release-state}"=="unreleased"]
31
30
@@ -44,12 +43,11 @@ docker pull {docker-repo}:{version}
44
43
endif::[]
45
44
46
45
[[docker-verify-signature]]
47
- ==== Optional: Verify the {es} Docker image signature
46
+ ==== Optional: Verify the image signature
48
47
49
- Although it's optional, we highly recommend verifying the signatures included with your downloaded Docker images to ensure that the images are valid.
48
+ Verify the signatures included in your {es} Docker images to ensure they're valid.
50
49
51
50
Elastic images are signed with https://docs.sigstore.dev/cosign/overview/[Cosign] which is part of the https://www.sigstore.dev/[Sigstore] project.
52
-
53
51
Cosign supports container signing, verification, and storage in an OCI registry.
54
52
55
53
ifeval::["{release-state}"=="unreleased"]
@@ -76,7 +74,7 @@ cosign verify --key cosign.pub {docker-repo}:{version} <2>
76
74
77
75
The command prints the check results and the signature payload in JSON format:
78
76
79
- [source,sh]
77
+ [source,sh,subs="attributes" ]
80
78
--------------------------------------------
81
79
Verification for docker.elastic.co/elasticsearch/elasticsearch:{version} --
82
80
The following checks were performed on each of these signatures:
@@ -87,47 +85,35 @@ The following checks were performed on each of these signatures:
87
85
88
86
endif::[]
89
87
90
- Now that you have verified the {es} Docker image signature, you can start a
91
- <<docker-cli-run-dev-mode,single-node>> or <<docker-compose-file,multi-node>>
92
- cluster.
93
88
94
89
[[docker-cli-run-dev-mode]]
95
- ==== Start a single-node cluster with Docker
90
+ ==== Run {es} in Docker
96
91
97
- ifeval::["{release-state}"=="unreleased"]
92
+ Use Docker commands to start a single-node {es} cluster for development or
93
+ testing. You can then run additional Docker commands to add nodes to the test
94
+ cluster.
98
95
99
- WARNING: Version {version} of the {es} Docker image has not yet been released.
96
+ TIP: This setup doesn't run multiple {es} nodes or {kib} by default. To create a
97
+ multi-node cluster with {kib}, use Docker Compose instead. See
98
+ <<docker-compose-file>>.
100
99
101
- endif::[]
102
100
103
- If you're starting a single-node {es} cluster in a Docker container, security
104
- will be automatically enabled and configured for you. When you start {es} for
105
- the first time, the following security configuration occurs automatically:
101
+ ===== Start a single-node cluster
106
102
107
- * <<elasticsearch-security-certificates,Certificates and keys>> are generated
108
- for the transport and HTTP layers.
109
- * The Transport Layer Security (TLS) configuration settings are written to
110
- `elasticsearch.yml`.
111
- * A password is generated for the `elastic` user.
112
- * An enrollment token is generated for {kib}.
103
+ ifeval::["{release-state}"=="unreleased"]
113
104
114
- You can then {kibana-ref}/docker.html[start {kib}] and enter the enrollment
115
- token, which is valid for 30 minutes. This token automatically applies the
116
- security settings from your {es} cluster, authenticates to {es} with the
117
- `kibana_system` user, and writes the security configuration to `kibana.yml`.
105
+ WARNING: Version {version} of the {es} Docker image has not yet been released.
118
106
119
- The following commands start a single-node {es} cluster for development or
120
- testing.
107
+ endif::[]
121
108
122
- . Create a new docker network for {es} and {kib}
109
+ . Create a new docker network.
123
110
+
124
111
[source,sh]
125
112
----
126
113
docker network create elastic
127
114
----
128
115
129
- . Start {es} in Docker. A password is generated for the `elastic` user and
130
- output to the terminal, plus an enrollment token for enrolling {kib}.
116
+ . Start an {es} container.
131
117
+
132
118
--
133
119
ifeval::["{release-state}"=="unreleased"]
@@ -140,78 +126,64 @@ endif::[]
140
126
ifeval::["{release-state}"!="unreleased"]
141
127
[source,sh,subs="attributes"]
142
128
----
143
- docker run --name es01 --net elastic -p 9200:9200 -it {docker-image}
129
+ docker run --name es01 --net elastic -p 9200:9200 -it -m 1GB {docker-image}
144
130
----
145
131
132
+ TIP: Use the `-m` flag to set a memory limit for the container.
133
+
134
+ The command prints the `elastic` user password and an enrollment token for {kib}.
135
+
146
136
endif::[]
147
137
--
148
- +
149
- TIP: You might need to scroll back a bit in the terminal to view the password
150
- and enrollment token.
151
138
152
- . Copy the generated password and enrollment token and save them in a secure
153
- location. These values are shown only when you start {es} for the first time.
139
+ . Copy the generated `elastic` password and enrollment token. These credentials
140
+ are only shown when you start {es} for the first time. You can regenerate the
141
+ credentials using the following commands.
154
142
+
155
- [NOTE]
156
- ====
157
- If you need to reset the password for the `elastic` user or other
158
- built-in users, run the <<reset-password,`elasticsearch-reset-password`>> tool.
159
- This tool is available in the {es} `/bin` directory of the Docker container.
160
- For example:
143
+ --
144
+ [source,sh,subs="attributes"]
145
+ ----
146
+ docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-reset-password
147
+ docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana
148
+ ----
149
+
150
+ We recommend storing the `elastic` password as an environment variable in your shell. Example:
161
151
162
152
[source,sh]
163
153
----
164
- docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-reset-password
154
+ export ELASTIC_PASSWORD="your_password"
165
155
----
166
- ====
156
+ --
167
157
168
- . Copy the `http_ca.crt` security certificate from your Docker container to
169
- your local machine.
158
+ . Copy the `http_ca.crt` SSL certificate from the container to your local machine.
170
159
+
171
160
[source,sh]
172
161
----
173
162
docker cp es01:/usr/share/elasticsearch/config/certs/http_ca.crt .
174
163
----
175
164
176
- . Open a new terminal and verify that you can connect to your {es} cluster by
177
- making an authenticated call, using the `http_ca.crt` file that you copied from
178
- your Docker container. Enter the password for the `elastic` user when prompted.
165
+ . Make a REST API call to {es} to ensure the {es} container is running.
179
166
+
180
167
[source,sh]
181
168
----
182
- curl --cacert http_ca.crt -u elastic https://localhost:9200
169
+ curl --cacert http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200
183
170
----
184
171
// NOTCONSOLE
185
172
186
- ==== Enroll additional nodes
187
-
188
- When you start {es} for the first time, the installation process configures a single-node cluster by default. This process also generates an enrollment token
189
- and prints it to your terminal. If you want a node to join an existing cluster,
190
- start the new node with the generated enrollment token.
173
+ ===== Add more nodes
191
174
175
+ . Use an existing node to generate a enrollment token for the new node.
176
+ +
192
177
--
193
- .Generating enrollment tokens
194
- ****
195
- The enrollment token is valid for 30 minutes. If you need to generate a
196
- new enrollment token, run the
197
- <<create-enrollment-token,`elasticsearch-create-enrollment-token`>> tool on your
198
- existing node. This tool is available in the {es} `bin` directory of the Docker
199
- container.
200
-
201
- For example, run the following command on the existing `es01` node to
202
- generate an enrollment token for new {es} nodes:
203
-
204
178
[source,sh]
205
179
----
206
180
docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node
207
181
----
208
- ****
209
- --
210
182
211
- . In the terminal where you started your first node, copy the generated
212
- enrollment token for adding new {es} nodes.
183
+ The enrollment token is valid for 30 minutes.
184
+ --
213
185
214
- . On your new node, start {es} and include the generated enrollment token.
186
+ . Start a new {es} container. Include the enrollment token as an environment variable .
215
187
+
216
188
--
217
189
ifeval::["{release-state}"=="unreleased"]
@@ -228,10 +200,16 @@ docker run -e ENROLLMENT_TOKEN="<token>" --name es02 --net elastic -it {docker-i
228
200
----
229
201
230
202
endif::[]
231
-
232
- {es} is now configured to join the existing cluster.
233
203
--
234
204
205
+ . Call the <<cat-nodes,cat nodes API>> to verify the node was added to the cluster.
206
+ +
207
+ [source,sh]
208
+ ----
209
+ curl --cacert http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200/_cat/nodes
210
+ ----
211
+ // NOTCONSOLE
212
+
235
213
===== Setting JVM heap size
236
214
If you experience issues where the container where your first node is running
237
215
exits when your second node starts, explicitly set values for the JVM heap size.
0 commit comments