0

I am running Influxdb image with mounted volume like this:

docker run -v $(pwd)/data:/var/lib/influxdb influxdb

This will create data/ directory owned by root:

$ ls -ld data/
drwxr-xr-x 5 root root 4096 Jun 10 10:47 data/

I can not find out how to mount volume under common user. It is not possible to move the directory unless logged in as root. I know I can chown the directory and I've found Docker container creating directories owned by root, I need them owned by 1000:1000, but I would like to know if Influxdb image can handle it on its own?

If I run it as current user:

docker run --user=$UID -v $(pwd)/data/:/var/lib/influxdb influxdb

I end up with:

run: create server: mkdir all: mkdir /var/lib/influxdb/meta: permission denied
Michal Špondr
  • 1,337
  • 2
  • 21
  • 44
  • 1
    In short, NO. The official docker image install and run influxdb within `root` user, unless you will create your own Dockerfile, build your own image with the exact same UID/GID as your host user. Otherwise, you will always have trouble to access/migrate data. Beside that, I think you can consider use named volume instead of mount host directory, see the [Backup, restore, or migrate data volumes](https://docs.docker.com/storage/volumes/#backup-restore-or-migrate-data-volumes). – Dai Jun 10 '20 at 09:32
  • @Dai Thanks for info regarding named volumes and backup. The main reason why I use mounted directory is the backup of data. – Michal Špondr Jun 10 '20 at 09:56

0 Answers0