How to fix permissions of /var/lib/docker?

Hi,
I’m running Docker version 20.10.22, on ArchLinux.

I’ve been running Docker for a while, and I noticed, it’s taking up A LOT of disk space because I do have A LOT of images :smile:

I decided to re-create the partitions on my hard drive, to free up some more space for Docker.

/var/lib/docker has been moved to a temporary location (another hard disk) while I was re-creating partitions and re-formatting my HD.
I then moved back everything, including this /var/lib/docker directory.
I remember I had a few (permission) warnings, while moving the files for /var/lib/docker.

No, I did not use rsync.
Yes, I should have used rsync.
I used the good ol’ MC! :joy:
(Midnight Commander has always been my best friend, but, not this time, apparently)

OK, so here’s the problem:
My docker images are basely usable. I’m getting a lot of different errors, about PERMISSIONS.
I read somewhere that the folder /var/lib/docker should have 701 permissions.
So, silly me went ahead and tried:

sudo chmod 701 /var/lib/docker -R

the -R (recursive) was not a good idea, apparently.
I completely messed the original permissions from the /var/lib/docker directory!

Now, I can run some images.
But I can’t BUILD anything :frowning:

I get this type of error all the time, while building a new image:

System error resolving 'archive.ubuntu.com:80' - getaddrinfo (13: Permission denied)

It’s not a networking problem, it’s a PERMISSION problem.

Is there any way I can restore the CORRECT PERMISSIONS on the /var/lib/docker directory?

This is the second topic in which I wanted to answer and I forgot to finish it and send it and I have just found it in the list of my drafts…

Docker Desktop runs containers in a virtual machine. /var/lib/docker is for Docker CE, not Docker Desktop unless it is different on Arch Linux. So I guess you didn’t really used Docker Desktop.

About the permission issue: In a situation like this, I would just stop Docker, remove the whole folder and pull every required image again and I would build all my local images again if it is necessary and run completely new containers mounting the same folders. In case you had local volumes managed by Docker, that should be in /var/lib/docker/volumes which you can copy somehwre else before removing the docker data root and bind mount the volumes to the new containers. You should never create any image which cannot be reproduced and never save data in containers so you don’t have to keep the containers. If you saved thata in containers and this is why you want to fix the permission of the docker data root, you can still (or you could when you posted the question :frowning: ) find that in the docker data root, copy out and mount it back to a new container.