简体   繁体   中英

WSL Ubuntu 20.04, The command 'docker' could not be found in this WSL 2 distro

I'm having an issue with running Docker commands in Ubuntu 20.04 on WSL.

I followed the official documentation to setup Docker and run it with Ubuntu on WSL distribution.

Now, I want to do the same in another distribution, Ubuntu 20.04.

Here is what I have tried so far:

  1. Using PowerShell with admin privileges, Ubuntu 20.04 is shown and set as the default, according to the Docker docs :

     wsl.exe -l -v wsl.exe --set-version Ubuntu-20.04 2 wsl.exe --set-default-version 2
  2. With Docker desktop application, Resources --> WSL Integration , Ubuntu-20.04 is added and Docker restarted and shown as active.

  3. In the regular Ubuntu WSL distribution, I get the following:

     george@DESKTOP-P9I14LM:~$ ls -l /mnt/wsl/docker-desktop/cli-tools/usr/bin total 158574 -rwxr-xr-x 1 root root 60513128 May 12 2022 com.docker.cli -rwxr-xr-x 1 root root 60178432 May 31 2022 docker -rwxr-xr-x 1 root root 6348800 May 31 2022 docker-compose -rwxr-xr-x 1 root root 12737304 May 31 2022 docker-compose-v1 -rwxrwxr-x 1 root root 9395712 May 31 2022 docker-credential-desktop.exe -rwxr-xr-x 1 root root 13205504 May 31 2022 hub-tool

    While on Ubuntu-20.04 I get No such file or directory .

  4. On Ubuntu 20.04:

     george@DESKTOP-P9I14LM:~$ ls -la /usr/bin/docker lrwxrwxrwx 1 root root 48 Dec 4 12:52 /usr/bin/docker -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker george@DESKTOP-P9I14LM:~$ ls /mnt/wsl/docker-desktop/cli-tools/usr/bin/ ls: cannot access '/mnt/wsl/docker-desktop/cli-tools/usr/bin/': No such file or directory

Am not familiar with this kind of issues, so please let me know in comments if there is any missing info I should add.

I would recommend you to install Virtual Box and download an Ubuntu virtual machine there. You would save yourself a lot of trouble.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM