Here is a sample Docker Compose file that you can use to set up the Elastic stack (also known as the ELK stack) using Docker:
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
environment:
- discovery.type=single-node
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
logstash:
image: docker.elastic.co/logstash/logstash:7.10.0
volumes:
- ./logstash/config:/usr/share/logstash/config
ports:
- "9600:9600"
- "5000:5000"
kibana:
image: docker.elastic.co/kibana/kibana:7.10.0
ports:
- "5601:5601"
volumes:
elasticsearch-data:
This Docker Compose file defines three services: Elasticsearch, Logstash, and Kibana. It specifies the Docker images to use for each service and maps the necessary ports to enable communication between the services. It also defines a volume for Elasticsearch data to ensure that data is persisted across container restarts.
To use this Docker Compose file, save it to a file (e.g., docker-compose.yml
) and run the following command:
docker-compose up
This will start the Elasticsearch, Logstash, and Kibana containers and bring up the ELK stack. You can then access Kibana by visiting http://localhost:5601
in your web browser.
I hope this helps! Let me know if you have any questions.