docker-compose搭建ELK
github已经有人弄好了,直接clone一下,
git clone https://github.com/deviantony/docker-elk.git
进入kibana目录kibana.yml修改密码,注意字符串加引号。
再进入docker-compose.yml修改es密码,注意字符串加引号。
# 启动
docker compose up -d
tips:
- 拉取docker.elastic.co的镜像贼慢,建议换成阿里云或其他国内镜像。
- es插件可以下载到elasticsearch/plugins,然后挂载一下,或者构建镜像过程中copy进去。
下面是我修改的docker-compose.yml,可供参考。
version: '3.2'
services:
elasticsearch:
build:
context: elasticsearch/
args:
ELK_VERSION: $ELK_VERSION
volumes:
- type: bind
source: ./elasticsearch/config/elasticsearch.yml
target: /usr/share/elasticsearch/config/elasticsearch.yml
read_only: true
- type: volume
source: elasticsearch
target: /usr/share/elasticsearch/data
# 增加 es 插件
- type: bind
source: ./elasticsearch/plugins
target: /usr/share/elasticsearch/plugins
ports:
- "9200:9200"
- "9300:9300"
environment:
ES_JAVA_OPTS: "-Xmx256m -Xms256m"
ELASTIC_PASSWORD: "123456"
discovery.type: single-node
networks:
- elk
logstash:
build:
context: logstash/
args:
ELK_VERSION: $ELK_VERSION
volumes:
- type: bind
source: ./logstash/config/logstash.yml
target: /usr/share/logstash/config/logstash.yml
read_only: true
- type: bind
source: ./logstash/pipeline
target: /usr/share/logstash/pipeline
read_only: true
ports:
- "5044:5044"
- "5000:5000/tcp"
- "5000:5000/udp"
- "9600:9600"
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
networks:
- elk
depends_on:
- elasticsearch
kibana:
build:
context: kibana/
args:
ELK_VERSION: $ELK_VERSION
volumes:
- type: bind
source: ./kibana/config/kibana.yml
target: /usr/share/kibana/config/kibana.yml
read_only: true
ports:
- "5601:5601"
networks:
- elk
depends_on:
- elasticsearch
networks:
elk:
driver: bridge
volumes:
elasticsearch:
启动成功就可以进kibana玩耍了,es 比较吃机器内存,但相比 gitlab 感觉好一丢丢。
docker-compose搭建ELK
https://blog.puresai.com/2021/09/10/370/