0

Basically I'm trying to setup a environment with elasticsearch and kibana with docker on a m1 mac. I've setup the de env variable DOCKER_DEFAULT_PLATFORMto linux/amd64. Everything seems fine on running the container but when I try to connect kibana to elastic they just can't see each other. This is my current docker-composer file:


  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:8.3.3-amd64
    environment:
      - discovery.type=single-node
      - node.name=elasticsearch1
      - cluster.name=docker-cluster
      - cluster.initial_master_nodes=elasticsearch1
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms128M -Xmx128M"
    ports:
      - 9200:9200
    networks:
      - my-network

  kibana:
    image: docker.elastic.co/kibana/kibana:8.3.3-amd64
    environment:
      SERVER_NAME: localhost
      ELASTICSEARCH_URL: http://localhost:9200/
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch
    networks:
      - my-network

Before that I was using links insted of networks, no luck with that either. From my terminal or browser I can see both elastic and kibana running on their respective ports. I'm without ideas here, appreciate any help!

EDIT docker ps output

CONTAINER ID   IMAGE                                                       COMMAND                  CREATED          STATUS          PORTS                               NAMES
265023669cfd   docker.elastic.co/kibana/kibana:8.3.3-amd64                 "/bin/tini -- /usr/l…"   14 minutes ago   Up 14 minutes   0.0.0.0:5601->5601/tcp              folha3_kibana_1
48ee37663dda   docker.elastic.co/elasticsearch/elasticsearch:8.3.3-amd64   "/bin/tini -- /usr/l…"   14 minutes ago   Up 14 minutes   0.0.0.0:9200->9200/tcp, 9300/tcp    folha3_elasticsearch_1
6b1f6dd9473f   redis                                                       "docker-entrypoint.s…"   14 minutes ago   Up 14 minutes   0.0.0.0:6379->6379/tcp              folha3_redis_1
2a3ade65634a   mysql:5.7                                                   "docker-entrypoint.s…"   14 minutes ago   Up 14 minutes   0.0.0.0:3306->3306/tcp, 33060/tcp   folha3_mysql_1

1 Answers1

0

ELASTICSEARCH_URL: http://localhost:9200/ should be http://my-network:9200/, localhost can't access elasticsearch container.

Codcodog
  • 11
  • 2
  • Makes total sense, I changed to it but it still doesn't work. ```Failed to open TCP connection to my-network:9200 (getaddrinfo: Name or service not known)```. – Lucas Santiago Jul 29 '22 at 02:34
  • Also changed to ```ELASTICSEARCH_HOSTS``` According to [this answer](https://stackoverflow.com/a/59006139/7047663) – Lucas Santiago Jul 29 '22 at 02:37