I have the following docker-compose file:
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:
All containers are build successfuly. Telegraf is inserting data in Influx. No errors are thrown. This happens only if the port 8086 is exposed. If I close the port 8086 no data is inserted but the database is visible from Grafana - datasource panel. When I'm saving the connection a message is displayed that the connection was successful. Is there a way to get data from Influxdb container without exposing port 8086 public?