https://www.docker.elastic.co/# 到这里选择需要的镜像进行下载
Create user defined network (useful for connecting to other services attached to the same network (e.g. Kibana)):
sudo docker network create somenetwork
Run Elasticsearch:
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
列出正在运行的镜像
sudo docker ps
启动/停止/重启/删除容器
sudo docker start/stop/restart/rm xxx
进入容器目录,可以进行修改
sudo docker exec -it CONTAINER_ID /bin/bash
使用docker-compose,安装文档
https://docs.docker.com/compose/install/#install-using-pip
创建docker-compose.yml文件
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.7.2
container_name: elasticsearch
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata1:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- esnet
elasticsearch2:
image: docker.elastic.co/elasticsearch/elasticsearch:6.7.2
container_name: elasticsearch2
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata2:/usr/share/elasticsearch/data
networks:
- esnet
volumes:
esdata1:
driver: local
esdata2:
driver: local
networks:
esnet:
将当前用户添加进docker用户组
sudo gpasswd -a ${USER} docker
启动集群
sudo docker-compose up -d