windows10 docker volume

windows 10 docker 挂载目录比较特殊需要用\进行路径转义

本机elk的docker-compose.yml示例:

version: '3'
services:
  elasticsearch:
    image: elasticsearch:6.4.1
    container_name: elasticsearch
    environment:
      - "cluster.name=elasticsearch" #集群名称为elasticsearch
      - "discovery.type=single-node" #单节点启动
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m" #jvm内存分配为512MB
    volumes:
      - C:\\Users\\Administrator\\Documents\\docker\\elasticsearch\\plugins:/usr/share/elasticsearch/plugins
      - C:\\Users\\Administrator\\Documents\\docker\\elasticsearch\\data:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
      - 9300:9300
    restart: always
  kibana:
    image: kibana:6.4.1
    container_name: kibana
    links:
      - elasticsearch:es #配置elasticsearch域名为es
    depends_on:
      - elasticsearch
    environment:
      - "elasticsearch.hosts=http://es:9200" #因为上面配置了域名,所以这里可以简写为http://es:9200
    ports:
      - 5601:5601
    restart: always
  logstash:
    image: logstash:6.4.1
    container_name: logstash
    volumes:
      - C:\\Users\\Administrator\\Documents\\docker\\logstash\\logstash-krvs.conf:/usr/share/logstash/pipeline/logstash.conf
    depends_on:
      - elasticsearch
    links:
      - elasticsearch:es
    ports:
      - 4560:4560
      - 5044:5044
      - 9600:9600
logstash-krvs.conf的文件内容是
input {
  tcp {
    mode => "server"
    host => "0.0.0.0"
    port => 4560
    codec => json_lines
  }
}
output {
  elasticsearch {
    hosts => "es:9200"
    index => "krvs-logstash-%{+YYYY.MM.dd}"
  }
}

 

使用PowerShell切换到docker-compose.yml的目录,使用命令进行启动

docker-compose up -d

 

posted @ 2020-12-28 23:11  小段-长沙  阅读(3160)  评论(0编辑  收藏  举报
可以转载,转载需注明出处