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?
Ubuntu 20.04 running inside a virtual machine.
Usualy when things don’t make sense to me, the docker package from the snap repository is involved.
Please execute this two commands and post the output.
snap list | grep docker
dpkg --list | grep docker
sunil@ubuntuVM:/media/sf_work/docker$ snap list | grep docker
sunil@ubuntuVM:/media/sf_work/docker$ dpkg --list | grep docker
ii docker-ce 5:20.10.8~3-0~ubuntu-focal amd64 Docker: the open-source application container engine
ii docker-ce-cli 5:20.10.8~3-0~ubuntu-focal amd64 Docker CLI: the open-source application container engine
ii docker-ce-rootless-extras 5:20.10.8~3-0~ubuntu-focal amd64 Rootless support for Docker.
ii docker-scan-plugin 0.8.0~ubuntu-focal amd64 Docker scan cli plugin.
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.
I believe this is causing the problem.
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.