Deploy Elasticsearch 5.1.1 Docker

The docker image can be pulled from Here. Firing up the container is straightforward. The following shows the command line, where /data/es is a host dir prepared for persisting the ES data, -p 9200:9200 maps the port 9200 within the container to the host.

docker run -d -p 9200:9200  -v /data/es:/usr/share/elasticsearch/data elasticsearch

Point your browser to YOUR_HOST_IP:9200 should return something similar to

{
  "name" : "1sl-DGB",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "LZkO1Gd6StG-Bl3V5-Sa-g",
  "version" : {
    "number" : "5.1.1",
    "build_hash" : "5395e21",
    "build_date" : "2016-12-06T12:36:15.409Z",
    "build_snapshot" : false,
    "lucene_version" : "6.3.0"
  },
  "tagline" : "You Know, for Search"
}

Depending on the default setting on the host OS, one might experience an error shown below:

[2016-12-10T00:40:17,055][INFO ][o.e.t.TransportService   ] [1sl-DGB] publish_address {172.17.0.2:9300}, bound_addresses {[::]:9300}
[2016-12-10T00:40:17,060][INFO ][o.e.b.BootstrapCheck     ] [1sl-DGB] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
ERROR: bootstrap checks failed
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2016-12-10T00:40:17,065][INFO ][o.e.n.Node               ] [1sl-DGB] stopping ...
[2016-12-10T00:40:17,102][INFO ][o.e.n.Node               ] [1sl-DGB] stopped
[2016-12-10T00:40:17,102][INFO ][o.e.n.Node               ] [1sl-DGB] closing ...
[2016-12-10T00:40:17,115][INFO ][o.e.n.Node               ] [1sl-DGB] closed

This can be caused by that some Linux distributions have low defaults in vm.max_map_count, which defines the number of virtual memory areas that a particular process can own. This setting can be temporarily changed by typing this in command line,

sudo sysctl -w vm.max_map_count=262144

or permanently set it in /etc/sysctl.conf.

Bring up Elasticsearch as a service in Docker Swarm

Assuming there is an overlay network es already exists, the following command line will create a ES service in Docker Swarm.

docker service create \
               --network es \
               --name es-master \
               -p 9200:9200 \
               --mount type=bind,source=/data/es,destination=/usr/share/elasticsearch/data \
               elasticsearch

This service can be accessed by other services within the same overlay network through es-master:9200.

Advertisements

One thought on “Deploy Elasticsearch 5.1.1 Docker

  1. Pingback: Setup a Docker Overlay Network on Multiple Hosts | Data Probe

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s