13

For developing an application, I need to run Elasticsearch 6 on an Apple Silicon Mac.

I've tried to run it with Docker. Reading Docker Desktop for Apple silicon, I've installed Rosetta2 with:

softwareupdate --install-rosetta

And added the --platform linux/amd64 command line option.

Running:

docker run -d --platform linux/amd64 --name elasticsearch  -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:6.8.18

I obtain the warning about the AVX instruction set:

OpenJDK 64-Bit Server VM warning: UseAVX=2 is not supported on this CPU, setting it to UseAVX=0

So I added the command line option : -e "ES_JAVA_OPTS=-XX:UseAVX=0", but I still obtain:

[2021-08-22T00:06:20,727][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [unknown] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: org.elasticsearch.bootstrap.BootstrapException: java.io.IOException: Cannot run program "/usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller": error=0, Failed to exec spawn helper: pid: 131, exit value: 1
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-6.8.18.jar:6.8.18]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.8.18.jar:6.8.18]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.8.18.jar:6.8.18]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.8.18.jar:6.8.18]
    at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.8.18.jar:6.8.18]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116) ~[elasticsearch-6.8.18.jar:6.8.18]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.8.18.jar:6.8.18]
Caused by: org.elasticsearch.bootstrap.BootstrapException: java.io.IOException: Cannot run program "/usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller": error=0, Failed to exec spawn helper: pid: 131, exit value: 1
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:167) ~[elasticsearch-6.8.18.jar:6.8.18]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.8.18.jar:6.8.18]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.8.18.jar:6.8.18]
    ... 6 more
Caused by: java.io.IOException: Cannot run program "/usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller": error=0, Failed to exec spawn helper: pid: 131, exit value: 1
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1142) ~[?:?]
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1073) ~[?:?]
    at org.elasticsearch.bootstrap.Spawner.spawnNativeController(Spawner.java:118) ~[elasticsearch-6.8.18.jar:6.8.18]
    at org.elasticsearch.bootstrap.Spawner.spawnNativeControllers(Spawner.java:86) ~[elasticsearch-6.8.18.jar:6.8.18]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:165) ~[elasticsearch-6.8.18.jar:6.8.18]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.8.18.jar:6.8.18]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.8.18.jar:6.8.18]
    ... 6 more
Caused by: java.io.IOException: error=0, Failed to exec spawn helper: pid: 131, exit value: 1
    at java.lang.ProcessImpl.forkAndExec(Native Method) ~[?:?]
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:313) ~[?:?]
    at java.lang.ProcessImpl.start(ProcessImpl.java:244) ~[?:?]
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1109) ~[?:?]
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1073) ~[?:?]
    at org.elasticsearch.bootstrap.Spawner.spawnNativeController(Spawner.java:118) ~[elasticsearch-6.8.18.jar:6.8.18]
    at org.elasticsearch.bootstrap.Spawner.spawnNativeControllers(Spawner.java:86) ~[elasticsearch-6.8.18.jar:6.8.18]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:165) ~[elasticsearch-6.8.18.jar:6.8.18]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.8.18.jar:6.8.18]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.8.18.jar:6.8.18]
    ... 6 more

Then I look at Machine learning settings in Elasticsearchedit , where it states:

Machine learning uses SSE4.2 instructions, so it works only on machines whose CPUs support SSE4.2. If you run Elasticsearch on older hardware, you must disable machine learning (by setting xpack.ml.enabled to false).

So I added the command line option: -e"xpack.ml.enabled=false", Elasticsearch now starts but nothing appears in the log and it doesn't answer to requests.

My question is: How to run Elasticsearch 6 on an Apple Silicon Mac ?

Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240
  • Note, for version 7, though it’s not currently linked from [the install docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/targz.html), you can change the `x86_64` to `aarch64` in the URL and download an ARM version , e.g., [`https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.2.0-darwin-aarch64.tar.gz`](https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.2.0-darwin-aarch64.tar.gz) – andrewdotn May 18 '22 at 18:28

5 Answers5

8

I just had this issue, i worked out that you can run elasticsearch using the curl instructions here, but wanted to use docker.

If you want to use my image, go ahead:

docker run -p 9200:9200 -p 9300:9300 tompreston377/elasticsearch

To make this image, I organized files like this:

.
├── Dockerfile-elastic
└── elasticsearch.yml

Dockerfile:

# Dockerfile-elastic.yml
FROM arm64v8/openjdk:8-jdk-buster

WORKDIR /usr

# add a non root user
RUN useradd -m elasticuser

# Download extras
RUN apt update
RUN apt install -y curl nano

# Download elasticsearch
RUN curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.23.tar.gz
RUN tar -xvf elasticsearch-6.8.23.tar.gz

# Add config
ADD elasticsearch.yml /usr/elasticsearch-6.8.23/config/elasticsearch.yml

RUN chown -R elasticuser: .
USER elasticuser

ENV JAVA_HOME=/usr/local/openjdk-18/bin/java
ENV discovery.type=single-node
ENV xpack.security.enabled: false
ENV xpack.ml.enabled: false

RUN cd elasticsearch-6.8.23/bin
RUN chown -R elasticuser: elasticsearch-6.8.23

EXPOSE 9200 9300
CMD cd /usr/elasticsearch-6.8.23/bin/ && ./elasticsearch

elasticsearch.yml:

# elasticsearch.yml
xpack.security.enabled: false
xpack.ml.enabled: false

http.host: 0.0.0.0
transport.host: 0.0.0.0

Commands:

Build: docker build -f Dockerfile-elastic -t elastic .

Run: docker run -p 9200:9200 -p 9300:9300 elastic

Preston
  • 7,399
  • 8
  • 54
  • 84
6

This is generally not supported, but there is a report that https://hub.docker.com/r/webhippie/elasticsearch/ might work.

If you didn't have a good reason to upgrade yet, maybe running it on M1 might help? Native support (without Rosetta) has been added in 7.12.

xeraa
  • 10,456
  • 3
  • 33
  • 66
  • 2
    `webhippie/elasticsearch` worked for me. Thank you! the latest version of ES that this image has is v6.4.0 – Armin Dec 19 '21 at 06:44
  • @Armin, did you have to do anything special to get webhippie to work? I'm having issues getting elasticsearch 6 running on my M1 laptop. Getting the same i/o exception error when it starts up, even after removing docker volumes and rebuilding. – robert.bo.roth Mar 29 '22 at 23:52
1

Found this github issue #81383

Adding -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" fixed the crash with 7.16.1.

Hope that helps

Franck
  • 71
  • 1
  • 2
1

Im struggled with this problem for a long time and here is what i found:

  • Regular version 6 or 7 does not work.
  • For version 7 you need to use docker.elastic.co/webhippie/elasticsearch:7.10.2-arm64
  • For version 6 webhippie/elasticsearch:6.4

I hope this information is useful for someone.

1

I myself faced this problem and could not fix it for a long time. Solution with For version 6 webhippie/elasticsearch:6.4 also works.

I was able to start the container elasticsearch:6.8.6 And that's what i did

  1. Add to es environment - xpack.security.enabled=false and - bootstrap.system_call_filter=false;
  2. Remove from es volumes.
  3. Add esdata to common volumes

Like this

 es:
    image: elasticsearch:6.8.6
    environment:
        - xpack.security.enabled=false
        - discovery.type=single-node
        - bootstrap.system_call_filter=false
    ports:
        - "9200:9200"
        - "9300:9300"

volumes:
    esdata:
    <--anything else-->

Maybe this solution can help someone