This image is based on the official Elasticsearch Docker image (https://www.docker.elastic.co/r/elasticsearch). No extra plugins are installed; it adds an entrypoint that manages users/passwords and transport SSL certificates.
Starting version 6.8.8, we have 2 Dockerfiles and 2 respective docker images: eeacms/elastic:VERSION and eeacms/elastic:VERSION-oss, VERSION containing the X-PACK modules, and the -oss version being without it.
To configure an Elastic Cluster using this image you can add parameters to the elasticsearch command so that the node can have a certain role in the cluster.
This ensures that the node can't hold data and can't be accessed with the HTTP API. Also this node can't run river processes.
esmaster:
image: eeacms/elastic:latest
environment:
ENABLE_READONLY_REST: 'false'
ES_JAVA_OPTS: -Xms512m -Xmx512m
KIBANA_HOSTNAME: kibana
TZ: Europe/Copenhagen
bootstrap.memory_lock: 'true'
cluster.name: es-cluster-noro
discovery.zen.ping.unicast.hosts: es-master
http.enabled: 'true'
node.data: 'false'
node.master: 'false'
node.name: $${HOSTNAME}
ulimits:
memlock:
hard: -1
soft: -1
nofile:
hard: 65536
soft: 65536
volumes:
- es-data:/usr/share/elasticsearch/data
ports:
- 9200:9200
This ensures that the node can't be elected as master and is in charge only for responding to HTTP requests for clients. You
esclient:
image: eeacms/elastic:latest
environment:
ENABLE_READONLY_REST: 'false'
ES_JAVA_OPTS: -Xms512m -Xmx512m
KIBANA_HOSTNAME: kibana
TZ: Europe/Copenhagen
bootstrap.memory_lock: 'true'
cluster.name: es-cluster-noro
discovery.zen.ping.unicast.hosts: es-master
http.enabled: 'true'
node.data: 'false'
node.master: 'false'
node.name: $${HOSTNAME}
ulimits:
memlock:
hard: -1
soft: -1
nofile:
hard: 65536
soft: 65536
volumes:
- es-data:/usr/share/elasticsearch/data
ports:
- 9200:9200
This ensures that the node only holds data without being accessible using the REST api and without being able to be elected as a master.
esdata:
image: eeacms/elastic:latest
environment:
ENABLE_READONLY_REST: 'false'
ES_JAVA_OPTS: -Xms512m -Xmx512m
TZ: Europe/Copenhagen
bootstrap.memory_lock: 'true'
cluster.name: es-cluster-noro
discovery.zen.ping.unicast.hosts: es-master
http.enabled: 'false'
node.data: 'true'
node.master: 'false'
node.name: $${HOSTNAME}
ulimits:
memlock:
hard: -1
soft: -1
nofile:
hard: 65536
soft: 65536
volumes:
- es-data:/usr/share/elasticsearch/data
Follow the instructions here: http://www.elastic.co/guide/en/elasticsearch/guide/master/heap-sizing.html
You can add the ES_HEAP_SIZE environment variable using
the -e Docker parameter. Alternativelly you can pass
the -Xmx and -Xms directly to the command that runs inside
the container.
Elasticsearch 8 logs via log4j2 (config/log4j2.properties from the base image);
the old logging.yml is no longer read. Log levels are normal Elasticsearch settings,
so they can be set with environment variables (-e, or environment: in compose):
# whole node at DEBUG (very verbose)
docker run -e logger.level=DEBUG ... eeacms/elastic:8.x
# only one package, e.g. action execution errors (what the old logging.yml did)
docker run -e logger.org.elasticsearch.action=DEBUG ... eeacms/elastic:8.x
Valid levels: OFF, FATAL, ERROR, WARN, INFO (default), DEBUG, TRACE.
On a running cluster you can change it without a restart:
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' \
-d '{"persistent": {"logger.org.elasticsearch.action": "DEBUG"}}'
# reset to default
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' \
-d '{"persistent": {"logger.org.elasticsearch.action": null}}'
Note: the base image only turns all-lowercase environment variable names into settings.
Loggers named after a Java class (with capitals, e.g. org.elasticsearch.http.HttpTracer)
are silently ignored as env vars; set them with the cluster settings API below instead.
Security audit logging (xpack.security.audit.*) needs a Platinum/Enterprise license; on the
free basic license it is disabled. As an alternative, the HTTP tracer logs every REST request
(method, path, client IP, response status), but not the user or the request body:
Enable it at startup with ENABLE_TRACING=true. By default /_cluster/health* and
/_nodes* are excluded; set the http.tracer.exclude env var to override that list.
docker run -e ENABLE_TRACING=true ... eeacms/elastic:8.x
Or on a running cluster, without restart:
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' \
-d '{"persistent": {"logger.org.elasticsearch.http.HttpTracer": "TRACE"}}'
The setting is persistent (survives restarts). To reduce noise, exclude paths, e.g.
"http.tracer.exclude": ["/_cluster/health*", "/_nodes*"] in the same call. Turn it off
by setting the logger to null. Run it against the node that receives client traffic
(the master/client node behind the load balancer).
The x-pack-inference module is removed from the image: even on a basic license it lets
any user with manage_inference (e.g. superuser, or anyone when security is disabled)
create an inference endpoint with an arbitrary url that Elasticsearch then calls, which
turns the cluster into an open HTTP proxy. As a consequence _inference and
semantic_text fields are not available.
Other outbound-call features are restricted in config/elasticsearch.yml:
watcher is disabled, reindex.remote.whitelist and repositories.url.allowed_urls are empty.
By default the data is stored inside a volume.
The voulume is mounted inside the container at /usr/share/elasticsearch/data
You can also create a propper data volume by running for example a busybox container
having as a volume /usr/share/elasticsearch/data
In order to create backups of the data just run another container with
--volumes-from. e.g. Make a backup on your local system at /path/to/backup.
docker run --volumes-from myelasticsearch -v /path/to/backup/:/backup busybox cp -r /usr/share/elasticsearch/data /backup
Alternatively you can mount that directory onto a local path
When running the Elastic cluster in production you would often want to monitor its health status and be notified when the cluster is downa or experience some stability issues.
A cluster health API is accessible at http://<elasticserver-ip>:9200/_cluster/health?pretty=true and returns a JSON response like:
{
"cluster_name" : "SearchServices",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 4,
"number_of_data_nodes" : 2,
"active_primary_shards" : 16,
"active_shards" : 32,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"number_of_pending_tasks" : 0
}
The status will tell you how healthy the cluster is. It can be green, yellow or red. More info at Elastic cluster health API.
Another Cluster stats API call will give even more details about memory usage, cpus usage, open file descriptors and so on.
docker pull eeacms/elastic:latest