Hi I am using the influxdb:2.0 container.
And I am mounting a volume. When I run the container the first time everything works.
But when I do docker compose down and then up. The startup complains that
“mkdir: cannot create directory ‘/var/lib/influxdb2’: Permission denied”
The directory where the volume is mounted.
This is the compose file, Any help would be greatly appreciated.
Your “volumes” are mount-binds. With mount-binds you need to make sure that the owner uid/gid of the host folder aligns with the uid/gid of the user inside the container that runs the process.
I am surprised the required UID/GID is not mentioned in the image description. A short inspection of the Dockerfile in github reveals UID 1000 and GID 1000
Stop you container, sudo chown 1000:1000 --recursive /media/sf_work/docker/influxdb, then restart the container.
Update: I should have looked at the entrypoint script. The container tries to chown the folders as required in the entrypoint script. Since you do not declare user:, your image is started as root and should change the owner of the folders as needed.
Could be a selinux, apparmor or acl problem. What OS are you running?
As I said this is a ubuntu 20.04 virtualbox VM running on a windows machine.
The directory I am running the docker folder from is shared between the ubuntu VM and the windows host.
Since the official docker package is used and the image is designed to start as root and create and/or chown the folders to the influxdb container user, the issue indeed is a mystery.
The shared folder between the Windows host and the vm might indeed be the reason. Even though you can influence how VBox mounts a windows folder into the vm, I doubt that you can actualy change the owner of mounted folders or it’s subfolders or add folders/files using a different user.