Skip to content

Commit bf09c9f

Browse files
jrodewigstefnestor
andauthored
[DOCS] Fix keystore creation instructions for Docker (#77155) (#77561)
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 df2e4cd commit bf09c9f

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
@@ -387,23 +387,60 @@ uid:gid `1000:0`**. Bind mounted host directories and files must be accessible b
387387
and the data and log directories must be writable by this user.
388388

389389
[[docker-keystore-bind-mount]]
390-
===== Mounting an {es} keystore
390+
===== Create an encrypted {es} keystore
391391

392-
By default, {es} will auto-generate a keystore file for secure settings. This
393-
file is obfuscated but not encrypted. If you want to encrypt your
394-
<<secure-settings,secure settings>> with a password, you must use the
395-
`elasticsearch-keystore` utility to create a password-protected keystore and
396-
bind-mount it to the container as
397-
`/usr/share/elasticsearch/config/elasticsearch.keystore`. In order to provide
398-
the Docker container with the password at startup, set the Docker environment
399-
value `KEYSTORE_PASSWORD` to the value of your password. For example, a `docker
400-
run` command might have the following options:
392+
By default, {es} will auto-generate a keystore file for <<secure-settings,secure
393+
settings>>. This file is obfuscated but not encrypted.
401394

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

408445
[[_c_customized_image]]
409446
===== Using custom Docker images
@@ -433,4 +470,48 @@ You must explicitly accept them either by:
433470
See {plugins}/_other_command_line_parameters.html[Plugin management]
434471
for more information.
435472

473+
[[troubleshoot-docker-errors]]
474+
==== Troubleshoot Docker errors for {es}
475+
476+
Here’s how to resolve common errors when running {es} with Docker.
477+
478+
===== elasticsearch.keystore is a directory
479+
480+
[source,txt]
481+
----
482+
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
483+
----
484+
485+
A <<docker-keystore-bind-mount,keystore-related>> `docker run` command attempted
486+
to directly bind-mount an `elasticsearch.keystore` file that doesn't exist. If
487+
you use the `-v` or `--volume` flag to mount a file that doesn't exist, Docker
488+
instead creates a directory with the same name.
489+
490+
To resolve this error:
491+
492+
. Delete the `elasticsearch.keystore` directory in the `config` directory.
493+
. Update the `-v` or `--volume` flag to point to the `config` directory path
494+
rather than the keystore file's path. For an example, see
495+
<<docker-keystore-bind-mount>>.
496+
. Retry the command.
497+
498+
===== elasticsearch.keystore: Device or resource busy
499+
500+
[source,txt]
501+
----
502+
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
503+
----
504+
505+
A <<docker-keystore-bind-mount,keystore-related>> `docker run` command attempted
506+
to directly bind-mount the `elasticsearch.keystore` file. To update the
507+
keystore, the container requires access to other files in the `config`
508+
directory, such as `keystore.tmp`.
509+
510+
To resolve this error:
511+
512+
. Update the `-v` or `--volume` flag to point to the `config` directory
513+
path rather than the keystore file's path. For an example, see
514+
<<docker-keystore-bind-mount>>.
515+
. Retry the command.
516+
436517
include::next-steps.asciidoc[]

0 commit comments

Comments
 (0)