Hello, I’m new to Docker and currently facing a beginner’s issue. Recently, Docker Desktop wouldn’t start and prompted me to reset it to factory settings. Unfortunately, at one point I clicked “Yes,” and although Docker Desktop did start afterward, all of my containers had disappeared.
Before resetting to factory defaults, I made a backup of the C:\ProgramData\DockerDesktop folder, which includes the file C:\ProgramData\DockerDesktop\vm-data\DockerDesktop.vhdx. I’ve tried restoring this file, but my containers still aren’t showing up.
Is there any way to recover them, or is it impossible after a factory reset? I haven’t found anything helpful in the forums. I’m using Windows 10 and Docker Desktop v4.37.0.
Unless you made a backup of the entire state of Docker Desktop, not just the disk, I don’t know how it can be restored. If you had all the required files then I don’t know what it was not successful. I never tried this. My guess is that even if you restored the disk, the WSL distribution (if you used th WSL2 backend) was not restored.
Data should not be stored on container filesystem so I assume you want to restore som anonymous or named volumes. If you can somehow mount the vhdx file in a WSL2 distribution, you could find the content of /var/lib/docker/volumes whch you could try to carefully backup with the original permissions, install a new Docker Desktop and restore the content later by copying it from the WSl2 distribution to a Docker volume.
First of all, I’d like to thank you for taking the time to try and help me. Although I didn’t follow your method in the article exactly, it did guide me to mount my VHDX file and examine its contents. Essentially, I used qemu-img to convert the image to VDI format and then mounted it in a Linux virtual machine. Unfortunately, I’m afraid the news isn’t good, since the recovered files don’t appear to allow me to restore my containers.
Still, I’m uploading the image here because I’m new to this and I could be mistaken, but it seems like I’ll have to start from scratch. Once again, thank you very much for your help.
Hello, and thank you once again for your time and help.
Let me clarify the situation. When I reset Docker Desktop to factory settings, as I mentioned, all my containers disappeared. Fortunately, I had previously made a backup of the C:\ProgramData\DockerDesktop folder by chance. After seeing my containers were gone, I checked that backup to see what information it might contain. Inside C:\ProgramData\DockerDesktop\vm-data, I found a file called DockerDesktop.vhdx, and I was hoping that file would let me recover my containers.
Following the article you recommended, I mounted the VHDX file and extracted its contents, as shown in the attached screenshot. For those who might find this useful: since I’m on Windows, I converted the VHDX file to a VDI using qemu-img, then mounted the resulting VDI in a VirtualBox VM. Once the disk was mounted, I could easily copy the folders to my Windows machine. However, in these recovered folders, I don’t see any directory named data. The most promising folder seemed to be docker\volumes, but it only contains a metadata.db file, which doesn’t appear to help recover my data.
Ultimately, it looks like the files I extracted from the VHDX won’t allow me to restore my containers—or at least I can’t find what I need. Most likely, I’ll have to reinstall all the containers and start from scratch. Again, thank you very much for your time. Best regards.
pd: I’ve attached the vhdx folder structure folders.txt (2.0 KB)
And you don’t need to. I wrote “docker data root” not “data” folder. The docker data root is /var/lib/docker on Linux normally, but this is Docker Desktop and the filestructure on the VM filesystem is different. Based on your folder structure, the “docker” folder I mentioned in my previous post is the docker data root, but if the txt contains all the files you found without hiding the content of “containers” and “overlay2”, you have no containers or any data. It is a completely new and empty docker data root. If this is indeed what you had in the backup, something went wrong with the backup and it is already a reset version of the folder.
The volumes folder is also empty so you have no volumes to restore at all.
Thank you, Rimelek. Indeed, I believe the data was not saved (which is strange because I made a direct copy of the entire vhdx), and now I have to reinstall all the containers. Regarding the comments from huyz and bluepuma77, although both points are valid in my opinion, I do think that DockerDesktop should somehow inform the user about the risks of restoring to factory settings, especially since it is a suggestion made by the software itself. It’s not something I had to search for, nor is its application difficult or confusing. The software simply fails to start and suggests restoring to factory settings, but it doesn’t warn that this will delete all your containers. You think, “This is a recommendation from the software itself, so it wouldn’t make sense for it not to warn about the potential dangers.” Yes, it’s true, we could check the manual to understand how the system will respond to that action, but initially, one wouldn’t expect such a drastic and final step. Once again, thank you all for your comments.
I admit I could start Docker Desktop first, so I don’t know how it recommends resetting to factory defaults when it cannot start. If it doesn’t warn you there, I AGREE, it should, even though my first assumption would be that I would lose data when I reset something to factory defaults, I accept that my brain might have been trained differently during the years in my profession so if you think there is a serious risk that Docker Desktop should warn you about or there is a missing feature, you can always ask for it in the RoadMap.
Or if you think something is a bug, you can also report it in other repositories:
We can help as a community, they can fix bugs and implement new features
Some explanation what I think why resetting has to delete data:
If the docker data root is corrupted somehow, the Docker Engine could not start without starting everything from scatch. I also guess that since Docker Desktop is for development, it doesn’t always seem like a serious risk to delete data, especially since persistent data that we really want to protect should be mounted from the host. On Windows, it could also mean mounted from a WSL distribution which would provide faster filesystem access for Linux containers. If it is not clear for users how Docker Desktop (or even Docker CE) handles data, there should probably be a note about that during the installation process as well. If I don1t forget it, I will recommend it to the developers later.
Thanks for reporting what bothers you in Docker Desktop, but don’t rely on me. If you want to let Docker developers know about any issue, make sure you use the links above and report it there too.