Fetch/update the Elastic Search image and check, CAREFUL about the version needed for the application e.g. ES v2.x.x,
docker pull elasticsearch:2 docker images
Make sure the data folder doesn’t exist yet otherwise the init part that follows doesn’t make sense,
ls -ld /data/elasticprod/ #sudo rm -rf /data/elasticprod/
Make sure the 9200 & 9300 ports are available on the docker host if you want to expose them,
netstat -antpe --inet --inet6 | grep LISTEN | egrep '9200|9300'
Launch the docker instance for ES and map the data volume to /data/elasticprod/
,
app=elasticprod volume=/data/$app docker ps -a | grep $app docker run -d --name $app -h $app -v $volume:/usr/share/elasticsearch/data elasticsearch:2 docker ps -a | grep $app docker logs $app
No need for -p 9200:9200 -p 9300:9300
even from the host. Check with,
nmap -p 9200,9300 172.17.0.2
If you need to further tweak the thing,
docker exec -ti $app bash cd /usr/share/elasticsearch/config/ cp elasticsearch.yml elasticsearch.yml.dist apt update apt install vim-tiny vi elasticsearch.yml
Eventually check that you can access the service from another container,
docker run -ti --link elasticprod:elastic ubuntu apt -y update && apt -y install netcat ping -c1 elasticprod nc -z -v elasticprod 9200 9300 #nmap -p 9200,9300 elasticprod
You can now inject the indexes to be used for the application(s).
Now check that you can see the indexes from that other container,
apt -y update && apt -y install curl curl 'elasticprod:9200/_cat/indices?v' curl -XGET 'http://elasticprod:9200/_cluster/health?pretty=true'
Note. the indices
command just lists the indexes, it doesn’t actually check if there is something in it.
Note. the health
command shows you the cluster status. It is green although we only have one node, which is weird (should be yellow).