Elasticsearch is also available as Docker images. The images use centos:7 as the base image.
A list of all published Docker images and tags is available at www.docker.elastic.co. The source files are in Github.
docker-compose is not pre-installed with Docker on Linux. Instructions for installing it can be found on the Docker Compose webpage.
The node elasticsearch listens on localhost:9200 while elasticsearch2 talks to elasticsearch over a Docker network.
To stop the cluster, type docker-compose down. Data volumes will persist, so it’s possible to start the cluster again with the same data using docker-compose up`. To destroy the cluster and the data volumes, just type docker-compose down -v.
The container runs Elasticsearch as user elasticsearch using uid:gid 1000:1000. Bind mounted host directories and files, such as custom_elasticsearch.yml above, need to be accessible by this user. For the data and log dirs, such as /usr/share/elasticsearch/data, write access is required as well. Also see note 1 below.
Some plugins require additional security permissions. You have to explicitly accept them either by attaching a tty when you run the Docker image and accepting yes at the prompts, or inspecting the security permissions separately and if you are comfortable with them adding the --batch flag to the plugin install command. See Plugin Management documentation for more details.
See Encrypting communications in an Elasticsearch Docker Container.
We have collected a number of best practices for production use. Any Docker parameters mentioned below assume the use of docker run.
By default, Elasticsearch runs inside the container as user elasticsearch using uid:gid 1000:1000.
One exception is Openshift which runs containers using an arbitrarily assigned user ID. Openshift will present persistent volumes with the gid set to 0 which will work without any adjustments.
As a last resort, you can also force the container to mutate the ownership of any bind-mounts used for the data and log dirs through the environment variable TAKE_FILE_OWNERSHIP; in this case they will be owned by uid:gid 1000:0 providing read/write access to the Elasticsearch process as required.
Use the ES_JAVA_OPTS environment variable to set heap size. For example, to use 16GB use -e ES_JAVA_OPTS="-Xms16g -Xmx16g" with docker run.
Pin your deployments to a specific version of the Elasticsearch Docker image. For example, docker.elastic.co/elasticsearch/elasticsearch:6.6.2.
If you are using the devicemapper storage driver, make sure you are not using the default loop-lvm mode. Configure docker-engine to use direct-lvm instead.