Image built with `docker compose build` raises "permission denied" when using `find` and rootless docker

I am running docker in Linux, specifically Pop!_OS 22.04. I followed installation instructions and enabled docker to run rootless. It all works fine except for one small quirk.

I installed docker to work on a collaborative project. The image is built with the docker compose build command, using Dockerfiles. That also runs just as expected.

However, if I try to run find from my home folder, I will get errors unless I use sudo find:

find: ‘./.local/share/docker/overlay2/4...8/work/work’: Permission denied

This occurs even if I try to exclude the path:

find . -name [filename] ! -path "./.local/share/docker/*"

This is merely an annoyance, but a solution would be greatly appreciated.

That folde is a special folder since it contains character special files to mark deleted files since those files cannot actually be deleted from lower layers. I guess this is why even the owner does not have access to the “work” folder. The fact that the user does not have read access either is strange. It must have a reason, but I don’t know.

If you need that folder for debugging so “find” can work without extra arguments, you can try to run a container and mount the docker data folder like this:

docker run --rm -it -v $HOME/.local/share/docker/:/var/lib/docker/ bash

Now you will have access to those files since the container “thinks” that you are root and root has access files even if nobody else has. Your user is still the owner by the way, so you could shange its permissions:

chmod u+rwx work/

Even if you do this, there could be files or folders with different user IDs without read and execute permissions to anyone, so the best way is to mount the whole docker folder into a container as I did above.