特定 version の Elasticsearch を Docker で構築する手順をご紹介します。
docker run -d \\
--name elasticsearch2.3.1 \\
-p 9200:9200 \\
-p 9300:9300 \\
-e "discovery.type=single-node" \\
elasticsearch:2.3.1
$ docker logs elasticsearch2.3.1 -f
[2019-02-13 06:44:50,342][WARN ][bootstrap ] unable to install syscall filter: seccomp unavailable: your kernel is buggy and you should upgrade
[2019-02-13 06:44:50,530][INFO ][node ] [Gertrude Yorkes] version[2.3.1], pid[1], build[bd98092/2016-04-04T12:25:05Z]
[2019-02-13 06:44:50,530][INFO ][node ] [Gertrude Yorkes] initializing ...
[2019-02-13 06:44:51,209][INFO ][plugins ] [Gertrude Yorkes] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
[2019-02-13 06:44:51,250][INFO ][env ] [Gertrude Yorkes] using [1] data paths, mounts [[/usr/share/elasticsearch/data (/dev/sda1)]], net usable_space [52.3gb], net total_space [58.4gb], spins? [possibly], types [ext4]
[2019-02-13 06:44:51,251][INFO ][env ] [Gertrude Yorkes] heap size [990.7mb], compressed ordinary object pointers [true]
[2019-02-13 06:44:53,848][INFO ][node ] [Gertrude Yorkes] initialized
[2019-02-13 06:44:53,848][INFO ][node ] [Gertrude Yorkes] starting ...
[2019-02-13 06:44:53,955][INFO ][transport ] [Gertrude Yorkes] publish_address {172.17.0.3:9300}, bound_addresses {0.0.0.0:9300}
[2019-02-13 06:44:53,963][INFO ][discovery ] [Gertrude Yorkes] elasticsearch/YB8vdaQeTCOkuXtPp33vUg
[2019-02-13 06:44:57,035][INFO ][cluster.service ] [Gertrude Yorkes] new_master {Gertrude Yorkes}{YB8vdaQeTCOkuXtPp33vUg}{172.17.0.3}{172.17.0.3:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2019-02-13 06:44:57,063][INFO ][http ] [Gertrude Yorkes] publish_address {172.17.0.3:9200}, bound_addresses {0.0.0.0:9200}
[2019-02-13 06:44:57,063][INFO ][node ] [Gertrude Yorkes] started
[2019-02-13 06:44:57,095][INFO ][gateway ] [Gertrude Yorkes] recovered [0] indices into cluster_state
最後に、curl コマンド経由で docker 上に構築した Elasticsearch へ接続確認しておきましょう。
$ curl http://localhost:9200/_cat/nodes\\?v
host ip heap.percent ram.percent load node.role master name
172.17.0.3 172.17.0.3 3 97 0.05 d * Gertrude Yorkes
Elasticsearch の停止
docker stop elasticsearch2.3.1
Elasticsearch の起動
docker start elasticsearch2.3.1
以上、たまに古い version の Elasticsearch が使いたくなる現場からお送りしました。