New Docker Install with persistent storage, Permission problem

I literally have no idea why this worked for me, but I think I have a solution.

TL;DR: user: ":" worked for me

What didn’t work for me:

  • Setting data folder ownership to 472:472
  • Setting “user:” to something meaningful, like my UID or UID:GID, or some IDs that correspond to the ownership of the host data directory

What did work:

  • Setting host folder permissions to 777, but I didn’t like it. I noticed though that with 777 permissions the files created by grafana were owned by some random user IDs, that might or might not depend on the “user:” setting provided in the docker-compose.yml

So I tried setting “user:” to “$UID:$GID”, but got a warning saying

WARN[0000] The "UID" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GID" variable is not set. Defaulting to a blank string. 

But in this case, the files created by the docker container were owned by my host user, not by a random UID (which was the case with all the other options, regardless of the user setting). Then I decided to get rid of warning and just set it to a blank string. And it worked, now all the files created by grafana are owned by my host user and everything works fine.

For some reason though user: "" doesn’t work, but user: ":" does.

It would be great if some docker guru explained this behaviour though.

2 Likes