Skip to main content

Elasticsearch volume and memory (Docker)

The Elasticsearch container holds vital Dataset data. Before any container maintenance, make sure the Elasticsearch data directory is mapped to the Linux host, so the data survives when the container is removed for maintenance or upgrades.

Image version

The examples below show an image: line for illustration. Keep it matching the Elasticsearch version your installation actually runs.

Add an Elasticsearch volume mount to the host

  1. From the Informer install root on the host, create a directory for the Elasticsearch data:

    mkdir esdata
  2. Stop Informer and bring up only Elasticsearch:

    docker-compose stop
    docker-compose start <elasticsearch service name>
  3. Copy the Elasticsearch data from the container to the host's esdata:

    docker cp <elasticsearch container name>:/usr/share/elasticsearch/data/. ./esdata
  4. Edit docker-compose.yml and add the volume mount to the Elasticsearch service:

    elasticsearch:
    environment:
    - TZ=timezonegoeshere
    - ES_JAVA_OPTS=-Xms4g -Xmx4g
    volumes:
    - ./esdata:/usr/share/elasticsearch/data
  5. Recreate the Elasticsearch container with the new mount:

    docker-compose stop
    docker-compose rm <elasticsearch service name>
    docker-compose up -d

Once Informer is back online, confirm Datasets still have query data, which proves the data persisted to the host mount.

Increase Elasticsearch memory

Elasticsearch is memory-intensive and is often the bottleneck for queries. By default it uses 2 GB, which is usually not enough; the minimum recommended is 4 GB, and 8 GB is common where resources allow.

Memory ceiling

Elasticsearch consumes all of its configured memory at startup and holds it. Never allocate more than 50% of the server's memory to Elasticsearch, and account for total server usage.

Make sure the Elasticsearch data directory is mounted to the host (above) before continuing.

  1. Stop the system:

    docker-compose stop
  2. Edit docker-compose.yml and set the memory in the Elasticsearch service's environment, changing 4g to the desired amount (the same value for -Xms and -Xmx):

    elasticsearch:
    environment:
    - TZ=timezonegoeshere
    - ES_JAVA_OPTS=-Xms4g -Xmx4g
    volumes:
    - ./esdata:/usr/share/elasticsearch/data
  3. Recreate the Elasticsearch container:

    docker-compose rm <elasticsearch service name>
    docker-compose up -d
  4. Follow the Elasticsearch logs to confirm the new memory settings on startup (look for the -Xms/-Xmx values in the JVM arguments):

    docker-compose logs -f elasticsearch