M1 Mac - Issue bringing up ElasticSearch. Cannot run jdk/bin/java
Asked Answered
M

4

19

Have done a bit of searching to no avail. Attempting to setup a project with an Elasticsearch docker container. Works on my older intel MacBook but no luck so far with the new system.

elasticsearch    | Exception in thread "main" java.io.IOException: Cannot run program "/usr/share/elasticsearch/jdk/bin/java": error=0, Failed to exec spawn helper.
elasticsearch    |  at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
elasticsearch    |  at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
elasticsearch    |  at org.elasticsearch.tools.launchers.JvmErgonomics.flagsFinal(JvmErgonomics.java:111)
elasticsearch    |  at org.elasticsearch.tools.launchers.JvmErgonomics.finalJvmOptions(JvmErgonomics.java:88)
elasticsearch    |  at org.elasticsearch.tools.launchers.JvmErgonomics.choose(JvmErgonomics.java:59)
elasticsearch    |  at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:95)
elasticsearch    | Caused by: java.io.IOException: error=0, Failed to exec spawn helper.
elasticsearch    |  at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
elasticsearch    |  at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:319)
elasticsearch    |  at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:250)
elasticsearch    |  at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
elasticsearch    |  ... 5 more
elasticsearch exited with code 1

Would greatly appreciate any help or pointing in the right direction!

Mcfarland answered 29/1, 2021 at 22:55 Comment(0)
G
28

Ran into this too with the image from dockerhub, but it seems using the official docker build from Elastic now works fine on my M1 Mac.

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.10.2
Grimbly answered 1/2, 2021 at 14:17 Comment(5)
This solution fixed the problem! Thanks for your help!Mcfarland
Fixed it for me as well on a M1 :-)Recent
Version 7.10.2 :)Weisberg
Interesting, thank you a lot, it worksHandel
``` $ docker --version Docker version 20.10.8, build 3967b7d ``` ``` $ docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.10.2 WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested Exception in thread "main" java.io.IOException: Cannot run program "/usr/share/elasticsearch/jdk/bin/java": error=0, Failed to exec spawn helper: pid: 233, exit value: 1 ``` Specifying docker run --platform=linux/amd64 fails, any ideas?Keldah
S
8

According to this comment: https://github.com/opendistro/for-elasticsearch-docs/issues/385#issuecomment-867198711 there are specific builds for Apple M1 with the suffix -arm64, example:

docker.elastic.co/elasticsearch/elasticsearch:7.10.2-arm64
Seashore answered 7/10, 2021 at 17:45 Comment(0)
U
2

For me below config worked on M1 mac

docker-compose.yml

version: '3.5'

services:

  my-elasticsearch:
    container_name: my-elasticsearch
    environment:
      - discovery.type=single-node
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.6
    ports:
      - 9200:9200
      - 9300:9300
    volumes:
      - my-elasticsearch-data:/usr/share/elastiscsearch/data:rw
Uproarious answered 19/10, 2022 at 14:43 Comment(0)
E
0

Change elasticsearch version from 7.5.1 to 7.10.2. (ELK_VERSION=7.10.2)

Ezekielezell answered 5/10, 2021 at 10:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.