我有以下 docker-compose 文件:
version: '2'
services:
# Define a Telegraf service
telegraf:
build: Services/Telegraf
image: jit-systems/telegraf
environment:
HOST_PROC: /rootfs/proc
HOST_SYS: /rootfs/sys
HOST_ETC: /rootfs/etc
volumes:
#- ./etc/telegraf.conf:/etc/telegraf/telegraf.conf:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- /sys:/rootfs/sys:ro
- /proc:/rootfs/proc:ro
- /etc:/rootfs/etc:ro
- /var/log/telegraf:/var/log/telegraf
links:
- influxdb
logging:
driver: json-file
options:
max-size: "100m"
max-file: "3"
networks:
- influx
- default
depends_on:
- influxdb
restart: always
# Define an InfluxDB service
influxdb:
image: influxdb:1.2.0
volumes:
#- ./data/influxdb:/var/lib/influxdb
- influxdb:/var/lib/influxdb
networks:
- influx
- default
#this port should not be exposed
ports:
- "8086:8086"
logging:
driver: json-file
options:
max-size: "100m"
max-file: "3"
restart: always
# Define a Kapacitor service
kapacitor:
image: kapacitor:1.2.0
environment:
KAPACITOR_HOSTNAME: kapacitor
KAPACITOR_INFLUXDB_0_URLS_0: http://influxdb:8086
volumes:
- influxdb:/home/docker_containers/kapacitor/volume
- influxdb:/var/lib/kapacitor
- /var/log/kapacitor:/var/log/kapacitor
links:
- influxdb
logging:
driver: json-file
options:
max-size: "100m"
max-file: "3"
networks:
- influx
- default
depends_on:
- influxdb
restart: always
grafana:
image: grafana/grafana
ports:
- 3000:3000
volumes:
- grafana:/var/lib/grafana
env_file:
- config.monitoring
links:
- influxdb
logging:
driver: json-file
options:
max-size: "100m"
max-file: "3"
restart: always
volumes:
influxdb:
portainer:
grafana:
networks:
influx:
所有容器都已成功构建。Telegraf 在 Influx 中插入数据。没有错误被抛出。仅当端口 8086 暴露时才会发生这种情况。如果我关闭端口 8086,则不会插入任何数据,但从 Grafana - 数据源面板可以看到数据库。当我保存连接时,会显示一条消息,表明连接成功。有没有办法在不公开端口 8086 的情况下从 Influxdb 容器获取数据?