influxdata / influxdata-docker

Official docker images for the influxdata stack
326 stars 248 forks source link

Kapacitor data volume mount #315

Open Menturan opened 5 years ago

Menturan commented 5 years ago

This issue is related to issue #56.

Data from kapacitor didn’t show up at the volume mounting point on the host. Below is a part of my docker-compose file:

influxdb...
chronograf...

kapacitor:
    image: kapacitor:1.5
    container_name: kapacitor
    hostname: kapacitor
    volumes:
      # Data directory
      - /var/metrics/data/kapacitor:/var/lib/kapacitor
      # Configuration
      - /var/metrics/config/kapacitor:/etc/kapacitor
    environment:
      KAPACITOR_INFLUXDB_0_URLS_0: http://influxdb:8086
      KAPACITOR_LOGGING_FILE: STDOUT
      KAPACITOR_LOGGING_LEVEL: ERROR
    links:
      - influxdb
    depends_on:
      - influxdb

After investigating inside the docker container to find out where the kapacitor data were stored I found it at /root/.kapacitor. I changed the mapping to this folder and the everything works fine.

      # Data directory
      - /var/metrics/data/kapacitor:/root/.kapacitor

Why isn’t the data stored in /var/lib/kapacitor?

Looking at the config that’s being copied in the Dockerfile, it looks fine.

ChrisAtGH commented 4 years ago

Hi there... I am very new 6 weeks to be exact in working with Docker and Ubuntu.. I have learnt a lot in the last 4 weeks about Docker and can answer your question if you never found out. I stumbled across this looking for something else.
When you mount a Folder in this way your are basically mounting or re-directing (however you mind thinks : ) the localhost folder before the : to a folder inside the container that is running the image with Kapacitor in it. That will be buried in the /var/ folder hiding.. :) So when data is written from Kapacitor to the : /var/lib/kapacitor folder in the container location it is actually being written to the folder that is on the left of the : in your case /var/metrics/data/kapacitor So you have to think about Left=Local:Right=Remote (or random, whatever word reminds you) :) I hope this rather long explanation helps... It took me 20 -30 hrs to get my head around -v and now the new volumes: -- commands in the docker-compose.yaml files.

Cheers.