1、编辑docker-compose.yml

创建一个目录elastic-stack,在elastic-stack目录下创建docker-compose.yml文件:

docker-compose.yml:

# 服务配置
services:
  elasticsearch:
    container_name: elasticsearch_8_15_2
    image: docker.elastic.co/elasticsearch/elasticsearch:8.15.2
    # 用来给容器root权限(不安全)可移除
    privileged: true
    # 在linux里ulimit命令可以对shell生成的进程的资源进行限制
    ulimits:
      memlock:
        soft: -1
        hard: -1
    environment:
      - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
      - "http.host=0.0.0.0"
      - "node.name=elastic_udaiot1000_node01"
      - "cluster.name=cluster_elasticsearch"
      - "discovery.type=single-node"
    ports:
      - "9200:9200"
      - "9300:9300"
    volumes:
      # - ./elasticsearch/config:/usr/share/elasticsearch/config
      - ./elasticsearch/data:/usr/share/elasticsearch/data
      - ./elasticsearch/plugin:/usr/share/elasticsearch/plugins
    networks: 
      - elastic_net
  kibana:
    container_name: kibana_8_15_2
    image: docker.elastic.co/kibana/kibana:8.15.2
    ports:
      - "5601:5601"
    #volumes:
    #  - ./kibana/config:/usr/share/kibana/config
    networks:
      - elastic_net
# 网络配置
networks:
  elastic_net:
    driver: b
10-07 02:34