I recently installed Windows 10 2004 which gives access to WSL2, In doing so, Docker Desktop gives you the option to enabled WSL2 support such that it switches from storing it's containers/volumes in Hyper-V to WSL2. I enabled this feature however it did not port over any of my existing containers or volumes from Hyper-V. Instead it just started fresh.
I was wondering if it is possible to move my existing containers/volumes from Hyper-V to WSL2 such that I don't lose all my volume data and have to rebuild all my containers?
To port over existing volumes from Docker on Hyper-V (i.e. pre-WSL2) to Docker based on WSL2:
Use the WSL 2 based engine
.Execute the following from an elevated Powershell terminal to backup the volume(s):
docker volume ls (find volume name you want to copy: some_volume)
docker run --rm -v some_volume:/volume -v c:\where-to-backup:/backup alpine tar -cjf /backup/backup.tar.bz2 -C /volume ./
Use the WSL 2 based engine
setting in Docker Desktop and restore the volume:docker run --rm -v some_volume:/volume -v c:\where-to-backup:/backup alpine tar -C /volume/ -xjf /backup/backup.tar.bz2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With