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

Akintola L. F. ADJIBAO
3 min readJan 18, 2022


4 Tips to spin up an Elasticsearch instance with Docker.

Photo by Jason Goodman on Unsplash

I’ve seen a lot of people complaining about the official Elasticsearch version hosted on the Docker hub. The reasons for their complaints are various and somehow real. However, trust me, there are ways to make Elasticsearch docker usage painless, easier, and convenient. That’s the sole purpose of this article.

In this article, I’ll share with you 5 really useful tips to ease Elasticsearch usage in your day-to-day tasks. Ready? Let’s get started.

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.

So my first tip for you is to always use images coming from that repository. The funny thing is that you’ll get more versions to choose from.

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.

First of all, one of the hard things I learned when it comes to designing an Elasticsearch cluster is that the best and quickest way to choose the right settings for your cluster is by trying and failing till your find the perfect values (number of nodes and so on).

The other reason is related to software development and I got acquainted with this one as I’ve been using Elasticsearch a lot for searching. For any development process, working with only one node you’ll get rid of some checking and requirements Boostrap checks done by Elasticsearch.

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.

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.


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.

Thank you’ll folks for reading. Till next time, take care! Bye.



Akintola L. F. ADJIBAO

AWS Community Builder, Software & DevOps Engineer, solving challenging problems https://www.upwork.com/freelancers/~01d11b6c65945a1160?viewMode=1