Skip to content

Commit 8787e85

Browse files
jrodewigstefnestor
andauthored
[DOCS] Fix keystore creation instructions for Docker (#77155) (#77560)
Currently, our Docker install docs instruct users to directly bind-mount the `elasticsearch.keystore` file. This can lead to errors: * If the keystore file doesn't already exist, Docker's `-v` flag will create `elasticsearch.keystore` as a directory. This will block the creation of the keystore file. * To add or update secure settings, the container needs access to other files in the `config` directory, such as `keystore.tmp`. This updates the Docker install docs to instruct users to bind-mount the `config` directory rather than `elasticsearch.keystore`. It also adds troubleshooting tips for errors related to the keystore. Co-authored-by: James Rodewig <[email protected]> Co-authored-by: Stef Nestor <[email protected]>
1 parent ffede86 commit 8787e85

File tree

1 file changed

+96
-15
lines changed

1 file changed

+96
-15
lines changed

docs/reference/setup/install/docker.asciidoc

Lines changed: 96 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -400,23 +400,60 @@ uid:gid `1000:0`**. Bind mounted host directories and files must be accessible b
400400
and the data and log directories must be writable by this user.
401401

402402
[[docker-keystore-bind-mount]]
403-
===== Mounting an {es} keystore
403+
===== Create an encrypted {es} keystore
404404

405-
By default, {es} will auto-generate a keystore file for secure settings. This
406-
file is obfuscated but not encrypted. If you want to encrypt your
407-
<<secure-settings,secure settings>> with a password, you must use the
408-
`elasticsearch-keystore` utility to create a password-protected keystore and
409-
bind-mount it to the container as
410-
`/usr/share/elasticsearch/config/elasticsearch.keystore`. In order to provide
411-
the Docker container with the password at startup, set the Docker environment
412-
value `KEYSTORE_PASSWORD` to the value of your password. For example, a `docker
413-
run` command might have the following options:
405+
By default, {es} will auto-generate a keystore file for <<secure-settings,secure
406+
settings>>. This file is obfuscated but not encrypted.
414407

415-
[source, sh]
416-
--------------------------------------------
417-
-v full_path_to/elasticsearch.keystore:/usr/share/elasticsearch/config/elasticsearch.keystore
418-
-E KEYSTORE_PASSWORD=mypassword
419-
--------------------------------------------
408+
To encrypt your secure settings with a password and have them persist outside
409+
the container, use a `docker run` command to manually create the keystore
410+
instead. The command must:
411+
412+
* Bind-mount the `config` directory. The command will create an
413+
`elasticsearch.keystore` file in this directory. To avoid errors, do
414+
not directly bind-mount the `elasticsearch.keystore` file.
415+
* Use the `elasticsearch-keystore` tool with the `create -p` option. You'll be
416+
prompted to enter a password for the keystore.
417+
418+
ifeval::["{release-state}"!="unreleased"]
419+
For example:
420+
421+
[source,sh,subs="attributes"]
422+
----
423+
docker run -it --rm \
424+
-v full_path_to/config:/usr/share/elasticsearch/config \
425+
docker.elastic.co/elasticsearch/elasticsearch:{version} \
426+
bin/elasticsearch-keystore create -p
427+
----
428+
429+
You can also use a `docker run` command to add or update secure settings in the
430+
keystore. You'll be prompted to enter the setting values. If the keystore is
431+
encrypted, you'll also be prompted to enter the keystore password.
432+
433+
[source,sh,subs="attributes"]
434+
----
435+
docker run -it --rm \
436+
-v full_path_to/config:/usr/share/elasticsearch/config \
437+
docker.elastic.co/elasticsearch/elasticsearch:{version} \
438+
bin/elasticsearch-keystore \
439+
add my.secure.setting \
440+
my.other.secure.setting
441+
----
442+
endif::[]
443+
444+
If you've already created the keystore and don't need to update it, you can
445+
bind-mount the `elasticsearch.keystore` file directly. For example, you can
446+
add the following to `docker-compose.yml`:
447+
448+
[source,yaml]
449+
----
450+
...
451+
volumes:
452+
...
453+
- type: bind
454+
source: full_path_to/config/elasticsearch.keystore
455+
target: /usr/share/elasticsearch/config/elasticsearch.keystore
456+
----
420457

421458
[[_c_customized_image]]
422459
===== Using custom Docker images
@@ -446,4 +483,48 @@ You must explicitly accept them either by:
446483
See {plugins}/_other_command_line_parameters.html[Plugin management]
447484
for more information.
448485

486+
[[troubleshoot-docker-errors]]
487+
==== Troubleshoot Docker errors for {es}
488+
489+
Here’s how to resolve common errors when running {es} with Docker.
490+
491+
===== elasticsearch.keystore is a directory
492+
493+
[source,txt]
494+
----
495+
Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: java.io.IOException: Is a directory: SimpleFSIndexInput(path="/usr/share/elasticsearch/config/elasticsearch.keystore") Likely root cause: java.io.IOException: Is a directory
496+
----
497+
498+
A <<docker-keystore-bind-mount,keystore-related>> `docker run` command attempted
499+
to directly bind-mount an `elasticsearch.keystore` file that doesn't exist. If
500+
you use the `-v` or `--volume` flag to mount a file that doesn't exist, Docker
501+
instead creates a directory with the same name.
502+
503+
To resolve this error:
504+
505+
. Delete the `elasticsearch.keystore` directory in the `config` directory.
506+
. Update the `-v` or `--volume` flag to point to the `config` directory path
507+
rather than the keystore file's path. For an example, see
508+
<<docker-keystore-bind-mount>>.
509+
. Retry the command.
510+
511+
===== elasticsearch.keystore: Device or resource busy
512+
513+
[source,txt]
514+
----
515+
Exception in thread "main" java.nio.file.FileSystemException: /usr/share/elasticsearch/config/elasticsearch.keystore.tmp -> /usr/share/elasticsearch/config/elasticsearch.keystore: Device or resource busy
516+
----
517+
518+
A <<docker-keystore-bind-mount,keystore-related>> `docker run` command attempted
519+
to directly bind-mount the `elasticsearch.keystore` file. To update the
520+
keystore, the container requires access to other files in the `config`
521+
directory, such as `keystore.tmp`.
522+
523+
To resolve this error:
524+
525+
. Update the `-v` or `--volume` flag to point to the `config` directory
526+
path rather than the keystore file's path. For an example, see
527+
<<docker-keystore-bind-mount>>.
528+
. Retry the command.
529+
449530
include::next-steps.asciidoc[]

0 commit comments

Comments
 (0)