Skip to content

Commit 5bc2917

Browse files
stefnestorjrodewig
andauthored
[DOCS] Fix keystore creation instructions for Docker (#77155)
* [DOC] Update Persist Keystore via Docker From feedback from ES Devs summarized in [^1], I believe this needs to reflect a directory mount rather than file mount to not error. Also adding in the two common mounting errors, but not sure if this is the right place for them. [^1] https://discuss.elastic.co/t/persist-elasticsearch-kibana-keystores-with-docker/283099 * feedback * Reorganize * reword * fix formatting * address review feedback * remove extra whitespace Co-authored-by: James Rodewig <[email protected]>
1 parent b0b5cbd commit 5bc2917

File tree

1 file changed

+97
-15
lines changed

1 file changed

+97
-15
lines changed

docs/reference/setup/install/docker.asciidoc

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

397397
[[docker-keystore-bind-mount]]
398-
===== Mounting an {es} keystore
398+
===== Create an encrypted {es} keystore
399399

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

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

416454
[[_c_customized_image]]
417455
===== Using custom Docker images
@@ -460,4 +498,48 @@ You should use `centos:8` as a base in order to avoid incompatibilities.
460498
Use http://man7.org/linux/man-pages/man1/ldd.1.html[`ldd`] to list the
461499
shared libraries required by a utility.
462500

501+
[[troubleshoot-docker-errors]]
502+
==== Troubleshoot Docker errors for {es}
503+
504+
Here’s how to resolve common errors when running {es} with Docker.
505+
506+
===== elasticsearch.keystore is a directory
507+
508+
[source,txt]
509+
----
510+
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
511+
----
512+
513+
A <<docker-keystore-bind-mount,keystore-related>> `docker run` command attempted
514+
to directly bind-mount an `elasticsearch.keystore` file that doesn't exist. If
515+
you use the `-v` or `--volume` flag to mount a file that doesn't exist, Docker
516+
instead creates a directory with the same name.
517+
518+
To resolve this error:
519+
520+
. Delete the `elasticsearch.keystore` directory in the `config` directory.
521+
. Update the `-v` or `--volume` flag to point to the `config` directory path
522+
rather than the keystore file's path. For an example, see
523+
<<docker-keystore-bind-mount>>.
524+
. Retry the command.
525+
526+
===== elasticsearch.keystore: Device or resource busy
527+
528+
[source,txt]
529+
----
530+
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
531+
----
532+
533+
A <<docker-keystore-bind-mount,keystore-related>> `docker run` command attempted
534+
to directly bind-mount the `elasticsearch.keystore` file. To update the
535+
keystore, the container requires access to other files in the `config`
536+
directory, such as `keystore.tmp`.
537+
538+
To resolve this error:
539+
540+
. Update the `-v` or `--volume` flag to point to the `config` directory
541+
path rather than the keystore file's path. For an example, see
542+
<<docker-keystore-bind-mount>>.
543+
. Retry the command.
544+
463545
include::next-steps.asciidoc[]

0 commit comments

Comments
 (0)