在Windows 10 (1909)安装了子系统ubuntu-20.04与windows-docker-2.3.0.3,在WSL1命令行下执行“docker ps”会出现如下问题:
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.
See https://docs.docker.com/docker-for-windows/wsl/ for details.
解决方案
首先在docker setting上设置如下图(红圈钩选中部份)
打开Windows PowerShell
wsl
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo apt remove gpg
sudo apt install gnupg1
sudo apt install software-properties-common
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get -y update
sudo apt-get -y install docker-ce
echo "export DOCKER_HOST=tcp://localhost:2375" >> ~/.bashrc && source ~/.bashrc
测试是否正常了
docker ps
参考: