While setting up a new local test environment specifically for Magento 2.4.x with Elastic Search on Alpine Linux ( Docker ) I had some problems with getting elastic search up and running.
1 2 3 4 5 6 7 8 9 10 11 12 |
# Use Alpine Linux FROM alpine:3.12 # Other stuff ENV ELASTICSEARCH_VERSION 7.9.1 RUN mkdir -p /opt/ && \ cd /opt && \ curl -Ls -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ELASTICSEARCH_VERSION-linux-x86_64.tar.gz && \ tar -xvf elasticsearch-$ELASTICSEARCH_VERSION-linux-x86_64.tar.gz && \ cd elasticsearch-$ELASTICSEARCH_VERSION/bin |
The first issue I had was related to a missing home path of JAVA. Because of that, I wasn’t able to start Elastic Search at all.
1 2 |
bash-5.0# ./elasticsearch ./elasticsearch-env: line 77: /opt/elasticsearch-7.9.1/jdk/bin/java: No such file or directory |
I’ve fixed it by setting the missing path for JAVA_HOME which I have added later to my profile settings. https://stackoverflow.com/questions/35325856/where-to-set-system-default-environment-variables-in-alpine-linux
1 2 |
bash-5.0# which java /usr/bin/java |
1 |
export JAVA_HOME=/usr |
The second issue was related to the JAVA version inside the docker container.
1 2 |
bash-5.0# ./elasticsearch future versions of Elasticsearch will require Java 11; your Java version from [/usr/lib/jvm/java-1.8-openjdk/jre] does not meet this requirement |
Alpine Linux has the required version in the repository, which made it easy to install the missing package with apk.
1 2 3 4 5 |
bash-5.0# apk add openjdk11-jre (1/2) Installing openjdk11-jre-headless (11.0.8_p10-r0) (2/2) Installing openjdk11-jre (11.0.8_p10-r0) Executing java-common-0.2-r0.trigger OK: 649 MiB in 157 packages |