Import says file does not exists

#1

Hi,
I installed InfluxDB with docker on a machine running CentOS. Now, I need to import a CSV file but the command line “influx -import -path=/path/to/my/file” keeps telling me “open /path/to/my/file: no such file or directory”. I am 100% sure that the path is correct.
Do you know if the problem comes from Docker ?

#2

Hi T ,
Is it possible that the file permissions
cause the problem ?

#3

Hi,
Thank you for your answer. The file has rights -rw-r–r-- so I don’t think it is the problem.

#4

Hi ,
can you try without specifying the file ?

 influx -import -path=/path/to/my

that should return the following error :

ERROR: reading standard input: read /path/to/my : is a directory

#5

No, it still throws the same error. If I try “influx -import -path=/” it shows the error you mentioned.

#6

If it throws the same error it means the directories are not accessible ?
you could try to put the file in / for testing purpose and to exclude
directory permission problems or doublecheck the permissions on directory level …

#7

Even with a file in the / directory I have the same error…

#8

my last idea :slight_smile:
… chown telegraf:telegraf yourfile

#9

It says “invalid user: ‘telegraf:telegraf’”

#10

Sorry , I removed my remark about telegraf ,
you are using
influx -import

nothing to do with telegraf

I found something about backups and that could be the same for import as well
I am starting to think you have to use something like

 docker run --rm \
  --entrypoint /bin/bash \
  -v $INFLUXDIR:/var/lib/influxdb \
  -v $BACKUPDIR:/backups \
  test_influxdb:latest \
  -c "influxd restore -metadir /var/lib/influxdb/meta -datadir /var/lib/influxdb/data -database stocks /backups/stocks.backup"

but for import ?

something like

docker run  ...       -c "influx import ...

but I am not sure , hope someone will have an answer

I also found this

and here is explained how to do that using telegraf
https://www.influxdata.com/blog/how-to-write-points-from-csv-to-influxdb/

#11

Thanks a lot for your help, I finally figured out what was going on.
The problem was that a Docker container can’t see the directories and files of the host machine. The only way to fix this is to mount a directory to the Docker container when launching it :

docker run -v /dir/path/on/host:/dir/path/in/container

I created a directory where I copied the files I wanted to import into InfluxDB and mounted it on the influxdb container. When calling “influx -import -path=/path/in/container” it works.

1 Like
#12

Thanks for your feedback ,
Good to know :slight_smile: