Installing elastic search server

I’m trying to install Elasticsearch server on

fly deploy -i

with 2gb of memory. It seems like it’s asking for more.

I haven’t deployed it but I would suspect it’s not that the memory is not available, it’s that you need to configure elasticsearch to tell it to use it. By using its config options.

The memory error config option/solution:

The file descriptor error config option/solution:

Both of those example are for docker run. You’re running fly deploy (naturally) here. How to translate the command? Hmm. Well … fly deploy does support a --build-arg … so personally I’d give that flag a try. See what happens.

Else maybe try them in the fly.toml [env] block. If not, hopefully someone else can answer!

Here’s the deploy command docs:

Did you figure out this problem?

I have tried to set the sysctl -w vm.max_map_count=262144 but permissions issues every time. Also, tried it from the entrypoint and cmd.

@dragonfire1119 Maybe @jmarsh24 did (I didn’t end up trying).

If not, what I’d do is to use a custom Dockerfile. Base image would be the elastic one, as if deploying directly. But since you then have control over it, you can edit /etc/sysctl.conf. That way the setting is on the host and so I can’t imagine you would have permissions issues, the way you do with e.g cmd. Check the accepted answer below:

Thanks for the reply.

I’m using a custom docker image.

FROM bitnami/elasticsearch:7.12.0

# Tried to change 
USER 1001
ENTRYPOINT [ "/opt/bitnami/scripts/elasticsearch/" ]


# shellcheck disable=SC1091

set -o errexit
set -o nounset
set -o pipefail
#set -o xtrace

sysctl -w vm.max_map_count=262144

# Load libraries
. /opt/bitnami/scripts/
. /opt/bitnami/scripts/

# Load environment
. /opt/bitnami/scripts/


if [[ "$1" = "/opt/bitnami/scripts/elasticsearch/" ]]; then
    info "** Starting Elasticsearch setup **"
    info "** Elasticsearch setup finished! **"

echo ""
exec "$@"

Error output

sysctl: permission denied on key 'vm.max_map_count'

I tried to copy a custom file to the docker container and it does not persist and change the vm.max_map_count.

COPY sysctl.conf /etc/sysctl.conf



Also tried the elasticsearch base image.

I’m also seeing that people say Docker can’t change those settings, only the host level can.

Ah. I’d hoped you could use COPY sysctl.conf /etc/sysctl.conf to apply it and it would persist. But seems not :frowning:

Er … that’s me out of ideas then! I wonder how other people do it. Maybe the other guy will get back with what they did.

Thanks for trying to help.

From what I see, vm.max_map_count has to be updated directly on the host system and not the container file, which does not work on

Anyone else had luck deploying ES to fly?

No, it needs permission on the node. From what I’ve read, the VM can’t do it.

Hey all. Are you currently using Elasticsearch in production?

I’m making an attempt at this currently to deploy sonarqube which uses elasticsearch. No dice so far.

What kids of problems are you having? Have you considered using a managed Elasticsearch provider?

I gave up and am just hosting it myself at home, I don’t think it’s possible on fly unfortunately.

Unforunately I don’t think it’s currently possible to deploy ElasticSearch on fly which is a huge disapointment, but I don’t think it’s realistically possible for Fly to rectify without causing possible issues.

The issue is ElasticSearch requires some non-default settings for various kernel parameters:

  • vm.max_map_count >= 262,144 to allow ES to create many many memory-mapped files.
  • fs.file-max >= 65535 to allow ES to open many fds

Because these are kernel parameters, they must be set on the container host system, they can’t be set from within a container.

As far as I’m aware these checks are hard-coded into the application and cannot be bypassed.

Machines run on Firecracker VMs, so each one has its own kernel. You are free to modify any sysctls:

❯ fly ssh console
Connecting to fdaa:1:d615:a7b:10d:fc64:91a9:2... complete
# sysctl vm.max_map_count
vm.max_map_count = 65530
# sysctl -w vm.max_map_count=262144
vm.max_map_count = 262144
# sysctl vm.max_map_count
vm.max_map_count = 262144