skip to Main Content

I want to transfer a Docker image from my Windows10 PC to another one, Fedora, using rsync. I can’t use WSL, I need WSL2 as the compiler says:

ubu@DESKTOP-QL4RO3V:/mnt/c/Windows/system32$ docker images                                                                                                                                                                                      
The command 'docker' could not be found in this WSL 1 distro.                                                           
We recommend to convert this distro to WSL 2 and activate                                                               
the WSL integration in Docker Desktop settings.                                                                                                                                                                                                 
For details about using Docker Desktop with WSL 2, visit:                                                                                                                                                                                       
https://docs.docker.com/go/wsl2/ 

But I think that as I have Docker desktop it is using WSL2:

enter image description here

But I don’t know how to run the wsl2 Docker is using for my own.

PS C:Usersantoi> wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu                 Running         1
  docker-desktop-data    Running         2
  docker-desktop         Running         2

2

Answers


  1. Docker Desktop images, containers, and volumes are stored in the special docker-desktop-data. As noted in this Super User question and my answer there, docker-desktop-data is not bootable (by design).

    If you really had to get to the filesystem, I’ve documented a way to do so there. But in general, you should not need to do this.

    Instead, use the normal docker commands (from WSL2, PowerShell, or CMD) to save the image to a tar file as documented in this answer:

    docker save -o <image.tar> <image_name>
    

    Then transfer the file using rsync or other means, and on the destination machine, import it via:

    docker load -i <image.tar>
    

    Again, that’s from WSL2, PowerShell, or CMD. But in your case, the Ubuntu instance is WSL1. That won’t work for Docker. You’ll need to convert it to WSL2.

    Just in case, I always recommend backing up your instance before converting it. From PowerShell:

    wsl --export Ubuntu ubuntu_backup.tar
    

    Then, once you have the backup:

    wsl --set-version Ubuntu 2
    wsl --set-default-version 2 # if desired
    

    After conversion, you shouldn’t see that error when running docker in Ubuntu.


    Side note — Docker Desktop "injects" the docker command into any WSL2 instance that you set in the "WSL Integration" tab in Settings. This should default to your "default" WSL2 instance, which (from your screenshot) is Ubuntu. The "real" docker command is inside docker-desktop, but it’s linked into Ubuntu for you.

    So by default, you should have all docker functionality directly in your Ubuntu instance. Neither docker-desktop nor docker-desktop-data are designed to be used directly by the end-user.

    Login or Signup to reply.
  2. You can access docker desktop WSL using the following command

    wsl -d docker-desktop
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search