一、通过docker-compose单节点的部署的方式来部署es的方式:
①、docker-compose的配置文件如下:
version: "3.5"services: elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:7.15.2 container_name: elasticsearch restart: always ports: - 9200:9200 volumes: - ./elasticsearch7/logs:/usr/share/elasticsearch/logs - ./elasticsearch7/data:/usr/share/elasticsearch/data - ./plugins/ik:/usr/share/elasticsearch/plugins/ik - ./elasticsearch7/config/single-node.yml:/usr/share/elasticsearch/config/elasticsearch.yml - ./elasticsearch7/config/jvm.options:/usr/share/elasticsearch/config/jvm.options - ./elasticsearch7/config/log4j2.properties:/usr/share/elasticsearch/config/log4j2.properties environment: - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - "TZ=Asia/Shanghai" - "TAKE_FILE_OWNERSHIP=true" #volumes 挂载权限 如果不想要挂载es文件改配置可以删除 ulimits: memlock: soft: -1 hard: -1 networks: base-env-network: aliases: - elasticsearch kibana: image: docker.elastic.co/kibana/kibana:7.15.2 container_name: kibana2 volumes: - ./elasticsearch7/config/kibana.yml:/usr/share/kibana/config/kibana.yml ports: - 15601:5601 ulimits: nproc: 65535 memlock: -1 depends_on: - elasticsearch networks: base-env-network: aliases: - kibana # docker network create base-env-networknetworks: base-env-network: external: name: "base-env-network"
②、启动es:docker-compose up -d
③、查看docker-compose的启动日志如下:浏览器访问es和kibana如下: