Hi All, I’ve mistakenly deleted the docker/overlay2/l folder but all my docker images and containers are still in tact. My understanding is this contains symlinks which allows the docker engine to match up the ids of containers/images/etc. to their actual file locations. As a result, I cannot attach or inspect any container or image, but they are still running in the background.
Is there a way to recover the symlinks? I can simply do ls in docker/overlay2 to get the list of things I need to link to, but I cant figure out how to match them to their respective image/layer id.
I can look in a specific folder and there are suspiciously relevant files e.g. docker/overlay2/abcdef1234/lower contains a bunch of information l/abc123:l/123abc:l/def456:l/162dfe.
Interesting question. Before the answer, let me note that this is a kind of mistake I think when I don’t recommend manually doing anything in the docker data root. I’m not saying it to you, but every future reader But mistake can happen if someone really needs to do some advanced debugging.
I think this command would generate a list of commands to restore the links and you can decide whether you execute them or not:
Make sure you run it in the “overlay2” folder under the docker data root. /var/lib/docker in your case.
Why I think it could work: After your question I tried to find out where my filenames were stored and it turned out that the link names are in each layer in the file called “link”. I didn’t think it would be as easy…
Note that I haven’t tested if this would be enough or it just restores part of the folder.
Just an example how the generated commands look like on my machine:
Thanks so much for this. I’ve learnt my lesson so I’m making a backup of the folder before I try this but will get back to you with how it goes. I’ve modified the echo command to link to {}/diff but the output is promising