I noticed my Elasticsearch could not be accessible via curl, so I started from scratch on a new vm.
I used this config file for docker-compose.yml:
version: '3.6'
services:
Elasticsearch:
image: elasticsearch:7.16.2
container_name: elasticsearch
restart: always
volumes:
- ./elastic_data:/usr/share/elasticsearch/data/
environment:
ES_JAVA_OPTS: "-Xmx256m -Xms256m"
discovery.type: single-node
ports:
- '9200:9200'
- '9300:9300'
networks:
- elk
Logstash:
image: logstash:7.16.2
container_name: logstash
restart: always
volumes:
- ./logstash/:/logstash_dir
command: logstash -f /logstash_dir/logstash.conf
depends_on:
- Elasticsearch
ports:
- '9600:9600'
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
networks:
- elk
Kibana:
image: kibana:7.16.2
container_name: kibana
restart: always
ports:
- '5601:5601'
environment:
- ELASTICSEARCH_URL=http://elasticsearch:9200
depends_on:
- Elasticsearch
networks:
- elk
volumes:
elastic_data: {}
networks:
elk:
With this template of .env file:
# Project namespace (defaults to the current folder name if not set)
COMPOSE_PROJECT_NAME=es
# Password for the 'elastic' user (at least 6 characters)
ELASTIC_PASSWORD=changeme
# Password for the 'kibana_system' user (at least 6 characters)
KIBANA_PASSWORD=changeme
# Version of Elastic products
#https://www.elastic.co/downloads/past-releases#elasticsearch
STACK_VERSION=8.8.2
# Set the cluster name
CLUSTER_NAME=docker-cluster
# Set to 'basic' or 'trial' to automatically start the 30-day trial
LICENSE=basic
#LICENSE=trial
# Port to expose Elasticsearch HTTP API to the host
ES_PORT=9200
# Port to expose Kibana to the host
KIBANA_PORT=5601
# Port to expose Fleet to the host
FLEET_PORT=8220
# Port to expose APM to the host
APMSERVER_PORT=8200
# APM Secret Token for POC environments only
ELASTIC_APM_SECRET_TOKEN=supersecrettoken
# Increase or decrease based on the available host memory (in bytes)
ES_MEM_LIMIT=3073741824
KB_MEM_LIMIT=1073741824
LS_MEM_LIMIT=1073741824
# SAMPLE Predefined Key only to be used in POC environments
ENCRYPTION_KEY=c34d38b3a14956121ff2170e5030b471551371ff2170ee5626eec58b04a30fae2
Then docker-compose up
and I have all the services running and fine. But I cannot access to the elasticsearch via curl. I tried curl http://elasticsearch:9200/
and I got curl: (6) Could not resolve host: elasticsearch
which I guess means name server not found. with curl 172.19.0.2:9200
I got curl: (7) Failed to connect to 172.19.0.2 port 9200 after 0 ms: Connection refused
and curl http://localhost:9200/
responds as curl: (56) Recv failure: Connection reset by peer
.
Any Idea?