Lost data after a docker upgrade
Description
This issue is closely related to #14453 although it derived to a different nature, this is why I'm spinning-off it from there.
After upgrading the Docker Desktop as a response to the normal prompt of "there's a new version", I (apparently) lost all of my data during the process of upgrade. There's a point in time today at which I don't see any images, containers, networks or volumes.
The context
- Version I had: Most probably I had 4.35
- Version trying to be updated: 4.36
- Version I currently have: 4.36 "dev build" as indicated in https://github.com/docker/for-win/issues/14453#issuecomment-2507992110
Running on Win11, with an underlying WSL2 layer. This configuration has worked perfectly during multiple years.
WSL Distro disappearing
As a context too, the current version pre-upgrading was 4.35 but I installed docker desktop so much time ago that in the past, I usually had 2 WSL distributions: docker-desktop and docker-desktop-data that were usually listed when I did wsl -l.
As of now, I don't see docker-desktop-data anymore. But I can't tell for certain if it "disappeared today" with the issue, or Docker Desktop already managed to "merge" to the new format that was changed at 4.30 at some previous moment. I'm not completely sure of when it happened the "distro vanishing".
What I can tell is that until yesterday night I usually had a approximately a dozen of containers permamently running in my laptop all working perfect and with zero issues. Some of the with named volumes, and some networks connecting them together. As for the images I had both downloaded images plus images built by me.
All this was present yesterday and I was working with it normally.
So all this data either was present in the docker-desktop-data WSL distro or was previously merged but it was there, perfectly up and running.
What happened today
- After upgrading the docker Desktop to v4.36 and restarting it, it failed to start with the message "more than one sd* disk in /sys/block" - This is why I jumped into the issue #14453
- After the failure of launch after upgrading, this sequence happened:
I copy this sequence here again, for simplicity to the reader but it was originally posted here https://github.com/docker/for-win/issues/14453#issuecomment-2511028320
- Downloaded the dev-version
- Run the installer
- After the installer run, I run docker desktop
- A black window with many logs appeared and at some point Avast was persistently complaining. I thought as it was a dev version and non-signed maybe that was not good for avast so I disabled avast.
- Finally the Desktop Docker GUI appeared and I could see the images, containers, volumes, etc. there inside so it seemed I did not loose anything.
- I rebooted the PC to check all was in place.
- After rebooting the PC, no images, no containers, no anything...
- Doing wsl --list I see Ubuntu-20.04 and docker-desktop but no docker-desktop-data.
Keypoints: step 5 => I see the data, step 8 => I don't see the data.
As a side-note, I double-checked: No listings on the GUI, and empty results in CLI with docker ps -a or docker image ls or docker volume ls. Nothing at all.
Additional info: After I saw there's no data, I unchecked the box "start when windows starts" and closed Docker desktop to avoid any possible extra damage. So I've not tried "re-launching" it again and again to avoid possible "rewriting" or "re-deletion" and whatnot.
Maybe I just re-launch it and the data appears again... but I wanted to make some backing-up before going that way.
Virtual disk existence?
After that I checked if the docker_data.vhdx existed - comment here: https://github.com/docker/for-win/issues/14453#issuecomment-2511301580
This file is 160 GB in size, so I expect it's "my data", not an "empty data virtual disk of that size" but I've not really checked the content yet (see below) at section [x]
Diagnostics
As requested, I sent the logs here https://github.com/docker/for-win/issues/14453#issuecomment-2511339756
Diagnostics ID: BB5FCCBA-A57A-422E-A449-A09F8402C9FD/20241202115602 (uploaded)
Backups [x]
After feeling to loose the data, I was affraid of starting Docker Desktop more times. I felt it could potentially destroy things. So I did not want to start it again "just to try" to avoid potential destruction, at least until making some backups.
Once the docker_data.vhdx has been located, and seen its 160 GB big, I just made a binary backup of the virtulal disk to another computer and did a sha1sum to check I have a "good backup".
What am I going to do now? Now I'm going to try to discover if I may "mount" Read-Only the vhdx somehow to see the contents and check if my data is in it or not.
- If I can't mount the
vhdxmaybe it's time to start Docker Desktop again to see what happens (now that I have a copy of the disk) - If I can mount the virtual disk RO then:
- If I can see my data there, I'll take a deep breath and the only remaining thing will be discover how to tell Docker Desktop to use it.
- If I cannot see my data there, the next step will be to discover where the data could potentially reside (if it's still there).
Please help!
Reproduce
See description
Expected behavior
Install the "dev build" and, after a reboot, continue seeing my containers, volumes, etc.
docker version
See description
docker info
See description
Diagnostics ID
BB5FCCBA-A57A-422E-A449-A09F8402C9FD/20241202115602
Additional Info
No response
Okey, so... I don't understand anything... but it seems I may access the data now (at least it seems so).
Backup
Now that I made a backup of docker_data.vhdx I feel secure to play with the original file. In the worst-case scenario I may restore the backup and be again "as now I am".
Trying direct access to the virtual disk files: FAIL
First, I used Mount-VHD and Dismount-VHD to test if I could access the data directly.
More info here:
- Mount-VHD https://learn.microsoft.com/en-us/powershell/module/hyper-v/mount-vhd?view=windowsserver2025-ps
- Dismount-VHD https://learn.microsoft.com/en-us/powershell/module/hyper-v/dismount-vhd?view=windowsserver2025-ps
- WSL mount https://learn.microsoft.com/en-us/windows/wsl/wsl2-mount-disk
So the steps are:
- On windows,
Mount-VHDto make a file appear as a disk to windows. - On windows,
wsl --mount xxxx --bareto make that disk appear as a block device inside the WSL distro - On the WSL distro, normal
mountto mount the block device in the filesystem.
This is what happened:
In PowerShell as Administrator:
> Write-Output "\\.\PhysicalDrive$(( Mount-VHD -Path C:\Users\xavi\AppData\Local\Docker\wsl\disk\docker_data.vhdx -ReadOnly -PassThru | Get-Disk ).Number)"
\\.\PhysicalDrive1
> wsl --mount \\.\PHYSICALDRIVE1 --bare
La operación se completó correctamente
Then in wsl, as root, it got set as /dev/sdd
# lsblk -f /dev/sdd
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
sdd
# mount /dev/sdd /mnt/xaviDisk/
mount: /mnt/xaviDisk: cannot mount /dev/sdd read-only.
It could not mount anything. So I unmounted it from Windows:
In PowerShell as Administrator:
> wsl --unmount \\.\PHYSICALDRIVE1
La operación se completó correctamente
> Dismount-VHD -Path C:\Users\xavi\AppData\Local\Docker\wsl\disk\docker_data.vhdx
Instead, if I try with ...wsl\main\ext4.vhdx instead of ...wsl\disk\docker_data.vhdx I could see the contents of it within the WSL.
Conclusions so far:
- I could use Mount-VHD and Dismount-VHD to create a disk from the *.vhdx file and set it ReadOnly
- I could properly read the contents from wsl\main\ext4.vhdx
- I could not properly read the contents from wsl\disk\docker_data.vhdx (not mounted).
Docker Desktop again. Will it work?
So at this moment I thought "okey, all lost"... what will I loose if I restart Docker Desktop again?
And... boummm... the images and the volumes and the containers (nearly*) all were back again.
I swear I saw it empty this morning! I did!!
What?!?
So... this arises me a question... where is my data (the one that I am currently seeing in the docker desktop) physically located? If there's no docker-desktop-data distro now, where's my real data?
I know, I know... I should backup the volumes "from the docker itself"... it's only just curiosity to understand what *.vhdx file finally contains my data to test if I could manually access it if I want.
Confidence state
When something fails and then suddently works, one feels like "hummm... why? and will it fail again?"
For example, I am scared to reboot again. Will I loose it again after a reboot? Why it did not appear this morning if the data is there tonight? What's the reason? Will it happen again?
Why I say "nearly*" before
The volumes are there and the containers having volumes mounted stated well.
Instead, all the containers having "bind mounts" to the real filesystem are stuck.
A few examples:
All of them were running with normality yesterday, I just picked a few:
Some running yesterday and that tonight run: appsmith, grist-prod, grist-test, mercuer, socks5, mysql-prod-5.7 or wordpress-multisite.
Some running yesterday that today do not start: devel-sf7, kibana, elasticsearch, followup-devel, devel-sf4, devel-php72
There's a common thing between the ones that fail... they have filesystem-bound mount points.
For example I try to start devel-sf7 and it says:
xavi@msi-laptop:/files/repos$ docker start devel-sf7
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /run/desktop/mnt/host/wsl/docker-desktop-bind-mounts/Ubuntu-20.04/f4aa79e429af3c4da5700e4561167336f3392f73dd44f8c0a11980292eb71663
Error: failed to start containers: devel-sf7
xavi@msi-laptop:/files/repos$
IDK if this is related to all the upgrade process and so on.
So... questions
- I see it now but... should we investigate why I did not see it this morning? (I do have the backup of the *vhdx if needed to explore)
- May I rely on that they won't disappear again? May I reboot my PC?
- Where are the files now stored for everything, now that there's no
docker-desktop-dataVM/distro? How can I check it out? - Why the "bind mounts" are all broken? Should I throw away those containers and relaunch them? Or should we take advantage of the state and check what's up with it to discover any underlying bug?
Thanks in advance!
Okey... I'm getting crazy...
Checked again the "Start docker when starting windows"
Rebooted... and.... you know what? Lost again!!
I start thinking that:
- When Windows starts maybe a different version of Docker Desktop is launching. (The GUI says it's v4.36)
- When Windows starts with the new devel-buidl maybe it starts it "before" some needed files are ready.
Then I click on the systray icon to stop it (lasted like 3 mins at stopping "nothing") and then opened it again from the start menu...
and... you know what??? they are back again!!!
Also showing v4.36.
Partial conclusion
So it seems not that the installer "deleted the data files" but that for some reason the new version "sometimes get the data files, sometimes does not".
I'll be more than happy to help debug what's going on. Let me know instructions.
@xmontero Thanks for the detailed explanation and for furthering the investigation. Really interesting finds. I am glad to see that your data is not lost! Now I'd also like to figure out why the data seems to disappear when auto-starting Docker Desktop on boot.
Some answers to your questions:
.. where is my data (the one that I am currently seeing in the docker desktop) physically located?
Your data is in docker_data.vhdx as you correctly identified. Docker Desktop doesn't need an extra docker-desktop-data distribution and manages its own VHDX, using a similar mechanism to what you've used to explore the virtual disk (wsl.exe --mount --bare <....>\docker_data.vhdx). Therefore, as you have now backed it up, you are safe to experiment with it.
Where are the files now stored for everything, now that there's no docker-desktop-data VM/distro? How can I check it out?
You can check the content of your virtual disk by manually mounting the disk in a WSL distribution, much like you did in your exploration above. For example wsl.exe --mount <....>\docker_data.vhdx --name mymountpoint.
Then you can access it, for example, from your ubuntu distribution with:
> wsl -d ubuntu
$ cd /mnt/mymountpoint
You'll see there's a data folder in there. That folder contains a number of subdirectories which contain the data used by the linux docker daemon. They are not straighforward to manually inspect, but they use the exact same format that the docker daemon would use on Linux.
Rember to wsl.exe --unmount <...>\docker_data.vhdx before starting Docker Desktop up again
Now, moving to the real question on why you don't see the data after a windows reboot. I'd ask you to try the following steps if you are happy to help debug.
Please, make sure to have a backup copy of docker_data.vhdx before proceeding.
Check the Docker Desktop version running when containers are present and when they are not
I'd expect them to be the same, but let's make sure of it. You can check the exact version (also known as build number) by clicking on About Docker Desktop on the tray icon. The build number is next to the main version, for example: 4.36.0 (176956).
Ensure you are running the WSL2 backend in both cases.
The other backends (Hyper-V and Windows Containers) use a different storage drive, so that could explain why you don't see the data.
- Confirm you are using WSL2: open Settings -> General. Make sure that
Use the WSL2 based engineis selected. - Confirm you are not using Windows containers: right-click on the tray whale icon. There should be an entry "switch to windows containers": that's what I'd expect. If instead you see an entry saying "switch to linux containers" it means that for some reason you are now using the windows containers backend.
Gather diagnostics immediately after starting
I'd kindly ask you to gather two more diagnostics. One immediately after starting Docker Desktop when the containers are missing. One more immediately after starting Docker Desktop when the containers are present. This will help me compare the logs and possibly spot the differences.
You can gather the diagnostics from Docker Desktop by clicking on the question mark icon on the top of the dashboard ("Troubleshoot") and then Get support.
Try restarting the engine
After staring DOcker Desktop with missing containers, could you try to hit "Restart" in the three dots menu on the bottom-left, next to the green "Engine running" label? Does that bring the containers back?
Manually explore the content of the /var/lib directory
Again this will help you manually compare the content of the docker folders when containers are present vs when containers are missing.
- Start Docker Desktop
- Enter the docker desktop distribution with
wsl -d docker-destop cd /tmp/docker-desktop-root/var/lib/docker- visually the content of this folder in the two cases.
Hi @andrea-reale thanks for your guiding.
I will try all of that and report accordingly. Nevertheless, I run a travel agency and I need to recover the lost time from yesterday and today and I need to pass quotations to clients, sort out travel documents, and all those kind of things.
I am writing to make you know that I received your guidance and I'll do ASAP but not probably today or tomorrow. If I don't sell trips, I dont eat :) you know!!
Just ACK all received and in the queue to be processed!
So I am going to paste the investigation results in TWO messages, the first is AFTER REBOOT with automatic start.
After reboot (no containers running, no images, all empty):
- 4.36.0 (176956)
- Use the WSL 2 based engine => checked
- Using linux containers => because there is the entry to swith to windows containers in the systray menu
- Diagnostics ID => BB5FCCBA-A57A-422E-A449-A09F8402C9FD/20241205091816
- Contents of data directory: empty containers
These are the visual proofs:
And here the results after a manual stop of the docker-desktop application and relaunching the docker desktop from the icon.
On manual start (data is present):
- 4.36.0 (176956)
- Use the WSL 2 based engine => checked
- Using linux containers => because there is the entry to swith to windows containers in the systray menu
- Diagnostics ID => BB5FCCBA-A57A-422E-A449-A09F8402C9FD/20241205093914
- Contents of data directory: there are contents
Particularly, the data directory:
- Has containers
- In the networks, the local-kv.db file is 500k long while the other one was 64k long
- In the images, the repositories.json is 47k while it was 19 bytes the other one
- Has volumes
These are the visual proofs:
Finally, without quitting the GUI and re-launching it, and just only proceeding to this:
Troubleshoot (icon "?") / Restart Docker Desktop All containers and settings are preserved / Restart
DOES bring back the data. So I can now see the containers in the list.
Diagnostics-Id: BB5FCCBA-A57A-422E-A449-A09F8402C9FD/20241205102327
NOTE:
- Despite of all this, I observe a weird behaviour with containers that have a bind-mount to the filesystem. I'll open a different issue. While most probably related or subordinated to this one, the nature of describing what's happening is different in essence.
- See section "Why I say "nearly*" before" in the previous posts. It continues happening that "bind-mounted containers" do not start.
Thanks for sharing all this detail, it's really helpful.
I am a bit puzzled by what I see, but it looks like the virtual disk used by your Ubuntu distribution has the same ID of the docker desktop disk; the ids should be unique, hence my puzzlement. My current theory is that on windows boot, while the docker desktop disk is still being mounted, it finds and mounts the Ubuntu disk instead of the correct one and hence the observed behavior.
If the theory is correct, we can try to resolve it relatively easily by changing the ID of the docker desktop disk:
- Quit Docker Desktop.
- Always make sure you have a backup of
$Env:LOCALAPPDATA\Docker\wsl\disk\docker_data.vhdx - Open a Powershell console and
cd into $Env:LOCALAPPDATA\Docker\wsl\disk - Get the current disk id by running
Get-VHD -Path .\docker_data.vhdxand take a note of theDiskIdentifierfield. - Generate and set another disk identifier by running
Set-VHD -ResetDiskIdentifier -Path .\docker_data.vhdxand confirm when prompted. - Confirm the disk identifier has changed with
Get-VHD -Path .\docker_data.vhdx
Restart Docker Desktop. You should see your containers. Restart Windows (with Docker Desktop autostart), hopefully you should see your containers.
Please, let me know how that goes and thanks for your support.
An alternative to the above, with the same effects, would be exporting your ubuntu distribution to a tar archive with wsl --export , unregistering the ubuntu distribution with wsl --unregister and importing it again with wsl --import. This alternative would however be a bit more time consuming than the above, which should instead be very quick to try out.
Wasn't that what originated #14453 by complaining about multiple disks with same identifiers?
Also I wonder... Am I the only one with duplicated IDs? I never set an ID by myself, so this ID-duplication has the origin at some software.
Will every person in the world have to manually re-write the disk IDs?
Hi @xmontero,
I understand where the confusion comes from, but this looks like a different kind of problem.
In #14453 there is a conflict between the disk associated to the old docker-desktop-data distribution and the new docker_data.vhdx. This is because, in some rare cases, the disk of the docker-desktop-data distribution remains attached to the WSL2 VM even after the docker-desktop-data distribution is unregistered. In that case, it is by design that the two disks have the same ID, as they are literally a copy of each other.
In your case, the docker_data.vhdx seem to have the same ID of the Ubuntu20.04 disk, according to what is reported in the diagnostics (but you can verify it yourself): this is unexpected and is the reason why all the rest of the reporters of #14453 did not experience the same behavior that you are.
While I cannot of course exclude that other users had the same issue that you did, so far you have been the only reporter. And it is because the consequences are quite impactful (data loss), that I am investing in trying to get to an end of your problem.
So, no: not every person in the world will have to manually re-write the disk IDs. However, this work here will hopefully help any other person that may ever encounter your same issue. Of course, I appreciate your help on the matter so far and if you do not feel confident or willing to perform the manual repair actions that I am suggesting, please feel free not to do so.
Ah I see. Thanks for your help. I'll try to find all the info you need.
I will come back soon with the tests.
First of all I want to confirm that reading the DiskIdentifier, for some reason I cannot yet figure out, the ID is the same for both disks, as you saw in the logs.
I'm not conscious of ever in my life having written the disk-ID to any of those disks, so I guess a) either some software has written an ID when it should not, or b) either it all my life both disks had the same ID without causing any previous issues.
This is the proof that the IDs are the same, reinforcing what you see in the logs:
Although I can't understand why this is the current state.
I have executed steps 5 and 6: Set the new ID and confirm the new ID has been set:
Manually starting the Docker Desktop makes the containers appear:
This means that changing the ID of the disk has not broken anything.
Let's reboot the PC and see what happens!
After rebooting, I get this weird situation:
- An error box appears, talking about the WSL integration "unexpectedly stopped"
- If I open the GUI, I see the containers
- If I open the WSL CLI I can't access the engine.
Here's a capture with alltogether at the same time on the screen:
I pressed the button "Gather Diagnostics" and it seems it both gathered and uploaded them, as it gave me a Diagnostics ID.
I paste the ID here: BB5FCCBA-A57A-422E-A449-A09F8402C9FD/20241208170519
I'm going to check the Disk IDs again before clicking on "Restart the WSL integration".
The DiskId have not been altered during reboot.
I'm going to press the button "Restart the WSL integration".
After pressing the button "Restart the WSL integration" the containers are also seen from inside the WSL bash:
I'm going to reboot again to see what happens.
Again. Repeatable.
Everytime I reboot the PC I may see the containers from the GUI but there's a pupup complaining about the WSL integration.
I gathered diagnostics again: BB5FCCBA-A57A-422E-A449-A09F8402C9FD/20241208172037
Additionally, as I stated in https://github.com/docker/for-win/issues/14461#issuecomment-2513232313 I can't start some containers.
A few days ago the container named devel-sf7 could not start so I moved it into does_not_start_upgrade_4_36_was_devel-sf7 and I re-launched it. The one named now devel-sf7 is a new one.
Still... I can't start even the new one:
I tried twice.
I gathered diagnostics. BB5FCCBA-A57A-422E-A449-A09F8402C9FD/20241208173848
This happens after a reboot with the disk-id changed, and the containers properly seen (although not all running).
If I stop the Docker Desktop and manually start it again, then some containers that were not able to start, now they start.
Here there are a few:
Those named as does_not_start_upgrade_4_36_* were the ones that did not start.
So... we have changed the disk-ID, we have got Docker Desktop to deal with the disk from the beginning, but there are 2 problems yet:
- Broken WSL integration after each reboot
- Some containers do not start
After pressing on the WSL integration button, it gets integrated.
After stopping + starting, the Docker Desktop, some of the containers taht failed to start, now do start.
Diagnostics ID: BB5FCCBA-A57A-422E-A449-A09F8402C9FD/20241208174950
Waiting for instructions.
I have been hit with the same issue whilst trying to resolve https://github.com/docker/for-win/issues/14453#issuecomment-2507992110
The context
- Updated to 4.36 (still had issue 14453)
- Tried deleting data for WSL as potential fix -> https://github.com/docker/for-win/issues/14453#issuecomment-2507562341
- Updated to 4.37
- Running on Win11, with an underlying WSL2 layer
All containers and data volumes have gone missing. and my work has come to a halt.
Where can I find the missing containers/data-images?