I’m using Docker with WSL2 on Windows 10.
There are two distributions related to Docker: “docker-desktop” and “docker-desktop-data”.
Is it okay to migrate all Docker stuff from one machine to another using wsl --export and wsl --import?
By Docker stuff, I mainly mean volumes and built images.
If I do that, should I export/import both “docker-desktop” and “docker-desktop-data”, or only eg docker-desktop-data"?
Should I install Docker for Windows in the new machine first, and then make the import?
Should I discard the “docker-desktop” and “docker-desktop-data” distributions in the new machine that the Docker for Windows installation creates?
And what if the WSL kernel version differs between the old and new machine - should one ensure that the versions match before the migration (“docker-desktop”)?
Any downsides with this approach of moving all Docker stuff to another machine?
(I know that if I need to migrate or create backups of eg Docker volumes and long-built images, I can do it manually by backing up data on volumes and restoring in the new machine and for images I can use save/load, but I was thinking that doing WSL export/import would be way faster if a quick migration from one machine to another would be needed, or lets say in case of hard drive failure and restoring the environment from a backup, in which case it would be okay to move all data and not cherry-picking)
Thanks in advance !
I dont know if this helps but here’s my experience.
I was looking for a portable solution where i can use docker(volumes, images) at home and the office. I installed docker desktop on my windows 11 laptop at home and windows 11 desktop in office. All I do is carry my hard drive to use docker at home and office to continue work.
Here is how i did it.
- Home Laptop - Open Docker Desktop, Settings>Resources>Browse> Disk image location “E:\Docker” E: Drive is my External HD. “Docker is the folder i created”. Apply and Restart.
- Office Desktop Insert External HD (E:, yours might be different) and go to E:\Docker\docker-data and rename DockerDesktopWSL to DockerDesktopWSL_(whatever you want to name).
- Office Desktop - Open Docker Desktop, Settings>Resources>Browse> Disk image location “E:\Docker\docker-data” and click select folder. “DockerDesktopWSL” folder should be created. If you get an error that means you did not rename DockerDesktopWSL folder from Step 2.If successful then a DockerDesktopWSL folder should be created.
- Office Desktop - Quit Docker Desktop , open powershell as administrator and type
wsl--shutdown. After that go into “E:\Docker\docker-data\DockerDesktopWSL_(whatever you named it)**\disk” there should ba a file named “docker_data” (20GB+) copy or move the file to new directory “E:\Docker\docker-data\DockerDesktopWSL\data” and click “yes” to replace the file in that destination. After that open Docker Desktop and let it load. EVERYTHING I WAS WORKING ON AT HOME, LOADS INTO MY DOCKER DESKTOP IN THE OFFICE.
I found this the easiest way instead of exporting and importing images, volumes, etc…
Hope this helps