In my case, the integration was correctly set in the docker-app, WSL2 was correctly the default wsl, and I wasn't able to solve unregistering the wsl docker instance and restarting the docker service like mentioned in other answers.
After some time, I noticed that the command docker-compose successfully worked. The issue was limited to the docker command.
I looked for all docker commands in the directory usr/bin, that is the path where docker-compose is located (which docker-compose), so runnining ls -l /usr/bin | grep docker, I found
drwxrwxrwx 1 root root 48 Nov 29 10:59 docker
lrwxrwxrwx 1 root root 56 Nov 29 10:59 docker-compose -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker-compose*
lrwxrwxrwx 1 root root 59 Nov 29 10:59 docker-compose-v1 -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker-compose-v1*
lrwxrwxrwx 1 root root 71 Nov 29 10:59 docker-credential-desktop.exe -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker-credential-desktop.exe*
lrwxrwxrwx 1 root root 50 Nov 29 10:59 hub-tool -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/hub-tool*
For some weird reason, docker wasn't a symbolic link but a directory.
I solved removing the directory and re-creating manually the symbolic link:
rm -rf /usr/bin/docker
sudo ln -s /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker /usr/bin/docker
apt installdocker within your WSL environment? You're going to need to install full docker for your windows OS, and then install the docker CLI tool within your WSL environment, pointing WSL's docker at your host machine's docker port. This should help: nickjanetakis.com/blog/…explorer.exe .which opened a network folder in which I had to copy all my projects from "c:\dev" ie. from Windows filesystem. After that nothing worked, and Fabrício's answer saved the day. Then in Ubuntu for Windows I executedcd dev/gitlab.mycompany.com/my-project/sub-projectand thencode .opened WSL version of my project in VS Code. Rebuilt docker containers and everything now works smoothly.