How to change influxdb storage location

I have installed influxdb in docker container (Kubernetes) and I have mounted a persistent volume to that container. But influxdb is not writing data to that volume.
Can anyone please tell me steps, so that influxdb will write data in particular volume.
Thanks

  • docker registry with nginx: no such host
  • Consul running on Docker HTTP health check returns “connection reset by peer”
  • How to configure autoscaling on docker swarm?
  • after delete docker image, why can still find the deleted image by _catlog api?
  • Docker - logging to Graylog2 container with GELF log-driver raises an error
  • Docker 1.12: Multiple replicas, single database
  • Php7 Redis Client on Alpine OS
  • Can't ping docker IPv6 container
  • Can't discover docker container on user defined network
  • How to disable OpenSSL version verification
  • How to use local docker images in Kubernetes?
  • .bash_profile does not work with docker php image
  • 2 Solutions collect form web for “How to change influxdb storage location”

    Short Answer:

       $ docker run -p 8083:8083 -p 8086:8086 \
              -v $PWD:/var/lib/influxdb \
              influxdb
    

    Modify $PWD with the path to external volume.

    Long answer:

    docker run -p 8083:8083 -p 8086:8086 influxdb
    

    By default this will store the data in /var/lib/influxdb. All InfluxDB data lives in there. To make that a persistent volume (recommended):

    $ docker run -p 8083:8083 -p 8086:8086 \
          -v $PWD:/var/lib/influxdb \
          influxdb
    

    Modify $PWD to the directory where you want to store data associated with the InfluxDB container.

    For example,

     $ docker run -p 8083:8083 -p 8086:8086 \
                  -v /your/home:/var/lib/influxdb \
                  influxdb
    

    This will store the influx data in /your/home on the host.

    If you pulled official influxdb image from docker library, the default path for data files is:

    /var/lib/influxdb
    

    To verify, Run an standalone instance:

    docker run -p 8083:8083 -p 8086:8086 \
          -v $PWD:/var/lib/influxdb \
          influxdb
    

    To check out the default config:

    docker run --rm influxdb influxd config > influxdb.conf
    

    Then use vim influxdb.conf

    To run influxdb with custom config:

    docker run -p 8086:8086 \
          -v $PWD/influxdb.conf:/etc/influxdb/influxdb.conf:ro \
          influxdb -config /etc/influxdb/influxdb.conf
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.