https://www.docker.elastic.co/# 到这里选择需要的镜像进行下载

    Create user defined network (useful for connecting to other services attached to the same network (e.g. Kibana)):

    1. sudo docker network create somenetwork

    Run Elasticsearch:

    1. sudo docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.7.2

    生产模式参考文档https://www.elastic.co/guide/en/elasticsearch/reference/6.7/docker.html

    列出正在运行的镜像

    1. sudo docker ps

    启动/停止/重启/删除容器

    1. sudo docker start/stop/restart/rm xxx

    进入容器目录,可以进行修改

    1. sudo docker exec -it CONTAINER_ID /bin/bash

    使用docker-compose,安装文档
    https://docs.docker.com/compose/install/#install-using-pip

    创建docker-compose.yml文件

    1. version: '2.2'
    2. services:
    3. elasticsearch:
    4. image: docker.elastic.co/elasticsearch/elasticsearch:6.7.2
    5. container_name: elasticsearch
    6. environment:
    7. - cluster.name=docker-cluster
    8. - bootstrap.memory_lock=true
    9. - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    10. ulimits:
    11. memlock:
    12. soft: -1
    13. hard: -1
    14. volumes:
    15. - esdata1:/usr/share/elasticsearch/data
    16. ports:
    17. - 9200:9200
    18. networks:
    19. - esnet
    20. elasticsearch2:
    21. image: docker.elastic.co/elasticsearch/elasticsearch:6.7.2
    22. container_name: elasticsearch2
    23. environment:
    24. - cluster.name=docker-cluster
    25. - bootstrap.memory_lock=true
    26. - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    27. - "discovery.zen.ping.unicast.hosts=elasticsearch"
    28. ulimits:
    29. memlock:
    30. soft: -1
    31. hard: -1
    32. volumes:
    33. - esdata2:/usr/share/elasticsearch/data
    34. networks:
    35. - esnet
    36. volumes:
    37. esdata1:
    38. driver: local
    39. esdata2:
    40. driver: local
    41. networks:
    42. esnet:

    将当前用户添加进docker用户组

    1. sudo gpasswd -a ${USER} docker

    启动集群

    1. sudo docker-compose up -d

    启动验证 http://ip:9200/_cat/health