第一步:如果是linux需要修改一个文件
执行 vim /etc/sysctl.conf
在文件里面追加上 vm.max_map_count=262144
这个内容,然后执行sysctl -p
第二步:安装docker
centos执行yum install docker
ubuntu执行 yum install docker
第三步:安装docker-compose
执行1:
sudo curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
执行2:
sudo chmod +x /usr/local/bin/docker-compose
第四步:创建docker网络
执行1
docker network create esnet
第五步:最重要,创建docker-compose.yml文件
创建docker-compose.yml文件,必须是这个名字,文件内容为
version: '2'
networks:
esnet:
external: true
services:
elasticsearch:
image: liaocheng/elasticsearch:6.4.0
container_name: elasticsearch
environment:
- network.host=0.0.0.0
- http.port=9200
- bootstrap.memory_lock=false
- bootstrap.system_call_filter=false
- cluster.name=elasticsearch
ports:
- "9200:9200"
- "9300:9300"
networks:
esnet:
aliases:
- elasticsearch
kibana:
image: liaocheng/kibana:6.4.0
container_name: kibana
depends_on:
- elasticsearch
networks:
esnet:
aliases:
- kibana
environment:
- SERVER_NAME=kibana
- ELASTICSEARCH_URL=http://elasticsearch:9200
- XPACK_MONITORING_ENABLED=true
ports:
- "5601:5601"
redis:
image: liaocheng/redis:5.0.3
container_name: redis
ports:
- "6379:6379"
command: redis-server --requirepass 123456
networks:
esnet:
aliases:
- redis
pythohSpider:
image: liaocheng/juejinspider:1.1
container_name: pythonSpider
networks:
- esnet
depends_on:
- elasticsearch
- redis
command: scrapy crawl JuejinSpider -s JOBDIR=/code/logs/JuejinSpider
第六步:启动
启动的时候必须和docker-compose在一个目录下面,执行 docker-compose up 开始下载,下载完成会自动启动,如果下次启动还是执行该命令,docker会检查本地是否有这些环境,如果有就不下载了,而是直接执行
停止执行 docker-compose stop