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
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 -p 9200:9200 -p 9300:9300 docker run -d --name $app -h $app -v $volume:/usr/share/elasticsearch/data elasticsearch:2 docker ps -a | grep $app docker logs $app
If you need to further tweak the thing,
docker exec -ti $app bash
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 elastic nc -z -v elastic 9200 9300
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 'elastic:9200/_cat/indices?v' curl -XGET 'http://elastic:9200/_cluster/health?pretty=true'
indices command just lists the indexes, it doesn't actually check if there is something in it.
health command shows you the cluster status, should be yellow since we only have one ES node right now.
Same command as for launching it the first time, see the
docker run command above.
See Operating Docker Containers for common operations.