Installing elastic search server

I’m trying to install Elasticsearch server on fly.io.

fly deploy -i docker.elastic.co/elasticsearch/elasticsearch:7.5.2

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/entry.sh" ]

entry.sh

#!/bin/bash

# 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/libbitnami.sh
. /opt/bitnami/scripts/libelasticsearch.sh

# Load environment
. /opt/bitnami/scripts/elasticsearch-env.sh

print_welcome_page

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

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

sysctl.conf

vm.max_map_count=262144

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 Fly.io.