docker-compose 部署 ELK

2022-10-27 15:16:22 浏览数 (1)

代码语言:javascript复制
mkdir /data/elasticsearch/{config,data,plugins}
vim /data/elasticsearch/docker-compose.yml

version: '3.7'
services:
  elasticsearch:
    image: elasticsearch:7.14.2
    container_name: elasticsearch
    hostname: elasticsearch
    networks:
      - elk
    volumes:
      - type: bind
        source: /data/elk/elasticsearch/plugins
        target: /usr/share/elasticsearch/plugins

      - type: bind
        source: /data/elk/elasticsearch/data
        target: /usr/share/elasticsearch/data

      - type: bind
        source: /data/elk/elasticsearch/config
        target: /usr/share/elasticsearch/config
    ports:
      - 9200:9200
      - 9300:9300
    environment:
      - cluster.name=elk
      - ES_JAVA_OPTS=-Xms512m -Xmx512m
      - discovery.type=single-node
    restart: always
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:9200" ]
      start_period: 20s

  kibana:
    image: kibana:7.14.2
    container_name: kibana
    hostname: kibana
    ports:
      - 5601:5601
    networks:
      - elk
    depends_on:
      - elasticsearch
    volumes:
      - /data/elk/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml
    environment:
      - "TZ=Asia/Shanghai"
      - "ELASTICSEARCH_HOSTS=http://elasticsearch:9200"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:5601" ]
      start_period: 20s

  logstash:
    image: logstash:7.14.2
    container_name: logstash
    hostname: logstash
    networks:
      - elk
    restart: always
    depends_on:
      - elasticsearch
    ports:
      - 5044:5044
      - 9600:9600
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:9600" ]
      start_period: 30s

  elastichd:
    image: containerize/elastichd:latest
    container_name: elastichd
    hostname: elastichd
    networks:
      - elk
    ports:
      - 9800:9800
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:9800" ]
      start_period: 10s

networks:
  elk:

0 人点赞