为什么我不能在centos7上真正运行docker telegraf容器?

时间:2019-05-19 03:06:32

标签: docker centos7 telegraf

首先,我通过docker client运行了一个influxdb容器。现在,我想运行一个telegraf容器,该容器收集容器的数据和虚拟机管理程序主机的数据,例如cpu \ mem \ diskio等。但是我失败了,泊坞窗日志显示我无法将自定义telegraf.conf映射到容器的/etc/telegraf/telegraf.conf。

基本信息:

  1. docker版本:1.13.1
  2. centos版本:centos7
  3. 内核版本:3.10.0-957.12.2.el7.x86_64

我尝试过的命令:

  1. Influxdb: 码头工人网络创建influxdb docker运行-d -p 8086:8086 -p 8083:8083 --name = influxdb --net = influxdb docker.io/influxdb

  2. Telegraf: 泊坞窗运行-d --name = telegraf --net = influxdb \ -e HOST_PROC = / host / proc \ -v / proc:/ host / proc:ro \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /root/telegraf.conf:/etc/telegraf/telegraf.conf:ro \ telegraf

[root @ localhost〜]#docker日志telegraf 2019-05-19T03:05:17Z我!启动Telegraf 1.10.4 2019-05-19T03:05:17Z E! [telegraf]运行代理程序时出错:未指定配置文件,并且在$ TELEGRAF_CONFIG_PATH,/ root / .telegraf / telegraf.conf或/etc/telegraf/telegraf.conf

中找不到一个

1 个答案:

答案 0 :(得分:0)

您可以尝试使用此docker-compose.yaml

version: '3'
services:
  influxdb:
    image: influxdb:1.7.8
    container_name: influxdb
    volumes:
      # Mount for influxdb data directory
      - ./monitoring/influxdb:/var/lib/influxdb
      # Mount for influxdb configuration
      - ./monitoring/influxdb/config/:/etc/influxdb/
    ports:
      - "8086:8086"
      - "8082:8082"
      - "8089:8089/udp"

  telegraf:
    image: telegraf:1.12.2
    container_name: telegraf
    environment:
      HOST_MOUNT_PREFIX: "/hostfs"
      HOST_PROC: "/hostfs/proc"
      HOST_SYS: "/hostfs/sys"
      HOST_ETC: "/hostfs/etc"
    volumes:
      # Mount for telegraf configuration
      - ./monitoring/telegraf/:/etc/telegraf/
      - /:/hostfs:ro
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on:
      - influxdb

  chronograf:
    image: chronograf:1.7.14
    container_name: chronograf
    environment:
      RESOURCES_PATH: "/usr/share/chronograf/resources"
    volumes:
      # Mount for chronograf database
      - ./monitoring/chronograf/data/:/var/lib/chronograf/
    ports:
      - "8890:8888"
    depends_on:
      - influxdb
      - telegraf

here,您可以找到如何配置telegraf插件以获取有关系统的信息