Elasticsearch With Docker: It Was Much Easier Than You Thought.

Photo by Jason Goodman on Unsplash

1- Use docker image from Elastic public repository

I’m not telling you anything new by saying that there are tons of docker images registries out there: Amazon Elastic Container Registry for AWS, Azure Container Registry for Microsoft Azure, Google Container Registry for GCP, and so on. Elastic has got its own.

2- Use a specific version of Elasticsearch and stick with that

I’ve seen people using the latest tag for the deployment configuration and that’s simply wrong in my opinion. Pick the Elasticsearch version that has got the current features that your application needs. Don’t think too much about what is going to need in 5 years, 10 years. That’s my second tip.

3- Use only one node while you’re in development or for testing purposes

Yes, I know that sometimes, you’d like to test how Elasticsearch will handle a certain amount of data. But in most cases, starting from a single node is the best option to go, and here’s why.

4- Understand and choose carefully your Elasticearch docker parameters

Here are a few parameters that are used for an Elastisearch Docker container that you’d like to spin up.

- memlock:

The memlock parameter specifies how much memory the default user can lock into its address space in kilobytes. In most cases, we can just give the default user access to unlimited space taking into account the available space.

ulimits:
memlock:
soft: -1
hard: -1

- discovery.type=single-node:

This environment variable tells Elasticsearch if you’re going to use one single node or not. As we said earlier, we want to use only one node for testing and development purposes. In production, however, you’ll need to indicate the other nodes that your current node can communicate with.

-bootstrap.memory_lock=true:

The memory lock can be a little bit tricky. Here is how I understand it: the operating system, when it needs memory, copies data from memory to reserved storage on the disk called swap. The problem is that Elasticsearch uses those data to serve requests responses. memory_lock=true will avoid that behavior and make Elasticsearch works better.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store