I ran into several issues while trying to get this to work. Here are the steps I had to complete to get it working. Hopefully this will save some hair on your head 😉
The main step is to go into the settings in Docker Desktop -> Resources and make sure that your distribution is enabled for docker.
- Make sure that you have no docker packages installed on your WSL distribution. Docker Desktop will deploy its own binaries, and any pre-existing binaries will confuse it. This issue exhibited itself for me with errors related to missing files around credentials.
- Remove any
DOCKER_HOSTenvironment variables. Docker Desktop will sort it out. Docker kept hanging for me until I fixed this.
- If you want to use docker as non-root user, add yourself to the
Errors / Issues I ran into:
docker.credentials.errors.InitializationError: docker-credential-desktop.exe not installed or not available in PATH – Fixed by 1 above.
docker-compose from WSL2 errors out – Again, fixed by 1
Unable to run
docker as non-root user – fixed by 3.
Docker hangs when run as non-root user – fixed by 2.