Skip to content

Commit

Permalink
Persist Elasticsearch data by default via named volume (#430)
Browse files Browse the repository at this point in the history
* Persist Elasticsearch data by default via named volume

* update volume declaration to long format

* Update README
  • Loading branch information
deviantony authored and antoineco committed Oct 1, 2019
1 parent 972a500 commit ac9913e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 29 deletions.
41 changes: 14 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ and description of the built-in Search Guard users.**
* [macOS](#macos)
2. [Usage](#usage)
* [Bringing up the stack](#bringing-up-the-stack)
* [Cleanup](#cleanup)
* [Initial setup](#initial-setup)
* [Setting up user authentication](#setting-up-user-authentication)
* [Injecting data](#injecting-data)
Expand All @@ -51,15 +52,13 @@ and description of the built-in Search Guard users.**
* [How to configure Logstash](#how-to-configure-logstash)
* [How to disable paid features](#how-to-disable-paid-features)
* [How to scale out the Elasticsearch cluster](#how-to-scale-out-the-elasticsearch-cluster)
4. [Storage](#storage)
* [How to persist Elasticsearch data](#how-to-persist-elasticsearch-data)
5. [Extensibility](#extensibility)
4. [Extensibility](#extensibility)
* [How to add plugins](#how-to-add-plugins)
* [How to enable the provided extensions](#how-to-enable-the-provided-extensions)
6. [JVM tuning](#jvm-tuning)
5. [JVM tuning](#jvm-tuning)
* [How to specify the amount of memory used by a service](#how-to-specify-the-amount-of-memory-used-by-a-service)
* [How to enable a remote JMX connection to a service](#how-to-enable-a-remote-jmx-connection-to-a-service)
7. [Going further](#going-further)
6. [Going further](#going-further)
* [Using a newer stack version](#using-a-newer-stack-version)
* [Plugins and integrations](#plugins-and-integrations)
* [Swarm mode](#swarm-mode)
Expand Down Expand Up @@ -120,6 +119,16 @@ You can also run all services in the background (detached mode) by adding the `-
If you are starting the stack for the very first time, please read the section below attentively.

### Cleanup

Elasticsearch data is persisted inside a volume by default.

In order to entirely shutdown the stack and remove all persisted data, use the following Docker Compose command:

```console
$ docker-compose down -v
```

## Initial setup

### Setting up user authentication
Expand Down Expand Up @@ -227,28 +236,6 @@ settings][trial-license]).

Follow the instructions from the Wiki: [Scaling out Elasticsearch](https://github.com/deviantony/docker-elk/wiki/Elasticsearch-cluster)

## Storage

### How to persist Elasticsearch data

The data stored in Elasticsearch will be persisted after container reboot but not after container removal.

In order to persist Elasticsearch data even after removing the Elasticsearch container, you'll have to mount a volume on
your Docker host. Update the `elasticsearch` service declaration to:

```yml
elasticsearch:

volumes:
- /path/to/storage:/usr/share/elasticsearch/data
```

This will store Elasticsearch data inside `/path/to/storage`.

> :information_source: (Linux users) Beware that the Elasticsearch process runs as the [unprivileged `elasticsearch`
user][esuser] is used within the Elasticsearch image, therefore the mounted data directory must be writable by the uid
`1000`.

## Extensibility

### How to add plugins
Expand Down
8 changes: 6 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: '3.2'

services:

elasticsearch:
build:
context: elasticsearch/
Expand All @@ -13,6 +12,9 @@ services:
source: ./elasticsearch/config/elasticsearch.yml
target: /usr/share/elasticsearch/config/elasticsearch.yml
read_only: true
- type: volume
source: elasticsearch
target: /usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
Expand Down Expand Up @@ -64,6 +66,8 @@ services:
- elasticsearch

networks:

elk:
driver: bridge

volumes:
elasticsearch:

0 comments on commit ac9913e

Please sign in to comment.