Running Elasticsearch in docker container should be straightforward, Following the official instructions, I could not establish. Here is how I solved the issue.

Today I decided to do some messing around with Elasticsearch on my machine. I wanted my experiments not to interfere with other developments on the on the same machine so I went with docker installation. Unfortunately the instructions provided on Dockerhub page were not enough. After running docker run -d elasticsearch, the ports were not mapped to 9200 and 9300 respectively. There were multiple threads regarding the issue (e.g.

The working solution was to run docker run --rm -p 9200:9200 -p 9300:9300 --name=es elasticsearch:latest

Parameter descriptions:

  • -p xxxx:yyyy will map the xxx host machine port to yyyy port in container
  • --name=[name] will give the container a name which you can use later to execute commands against (e.g. docker stop es)
  • --rm will clean up after the container after it is stopped e.g. removing data directory
  • has to be after the image name so that the parameters would be passed to the command running inside container
comments powered by Disqus

Join my newsletter

I will send you occasional email about new approaches, learnings and experiments I have conducted