0

I am trying to run and use Elastic on my Mac M1 Pro via Docker.

It's older project so there is elasticsearch:2-alpine image. However, with docker-compose, everything starts just fine. Container is up and running, there are no errors, nothing in the terminal, no bumps. Nevertheless, Elastic is not reachable. It's running as AMD emulation, but not errors, warning etc. I can even go into it via terminal in Docker Desktop.

Everything else is up to date (OS X, Docker etc) and every other part of this project works (mysql, nginx, mail, php, rabbitmq, redis) and of course web app is up and running and fine.

curl localhost:9200 curl: (52) Empty reply from server curl http://elasticsearch:9200/ curl: (6) Could not resolve host: elasticsearch

docker ps results in this:

CONTAINER ID: 122595fee114
IMAGE: elasticsearch:2-alpine
COMMAND: "/docker-entrypoint.…"
CREATED: 22 minutes ago
STATUS: Up 21 minutes
PORTS: 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp
NAMES: elasticsearch

There are some setup information:

network.host: 0.0.0.0 in elasticsearch.yml (+ index.max_result_window: 100000 is defined there, nothing else)

part of docker-compose.override.yml this image is not available in ARM so I am forcing AMD

elastic:
        hostname: elasticsearch
        container_name: elasticsearch
        image: elasticsearch:2-alpine
        platform: linux/amd64
        restart: on-failure
        volumes:
            - elastic_data:/usr/share/elasticsearch/data
            - ./config/elasticsearch/local:/usr/share/elasticsearch/config
        ports:
            - 9200:9200
            - 9300:9300

volumes:
    elastic_data:

I am fullstack, but quite new in the DevOps Docker world. Thanks for any advice!

I already searched the whole internet and SO, 99% of the problems is about Elastic not being reachable from other container, I know solutions with adding network and dependes, however my Elastic is not reachable at all.

1 Answers1

0

add network_mode: "host" to the docker-compose.yml to curl elasticsearch with localhost.

Also, you can check this question.

Musab Dogan
  • 1,811
  • 1
  • 6
  • 8
  • unfortunately, this did not worked :/ Elastic is still not reachable from PHP nor from the outside (I am trying to use Elasticsearch plugin for Chrome to see what happening inside and to init some data) I had the same problem with rabbitMQ, but adding the hostname sorted that problem and now it runs smoothly – Martin Svolik Apr 05 '23 at 09:20