- In Powershell, install scoop:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser # Optional: Needed to run a remote script the first time irm get.scoop.sh | iex
- In Powershell, install WSL2:
wsl --install - In Powershell, install Rancher-Desktop:
scoop install rancher-desktop - Read carefully and follow the post-install instructions from the terminal.
- Open Rancher Desktop
- On welcome screen of Rancher-Desktop, check
dockerd (moby)(source). - Uncheck
Kubernetes. - Click on "Accept".
- In Rancher Desktop, on the home screen uncheck
Check for updates automatically. - In Rancher Desktop, File > Preferences > WSL > Choose your distro (for example
Ubuntu) > click on "Apply". - In distro terminal, to check if Docker is installed correctly, run this line:
docker ps
- In distro terminal, because of some issues explained in the Troubleshooting section, run the following:
sudo apt install pass libsecret-1-0
- In distro terminal, to check is Docker can run a container correctly, run this line:
docker run -it hello-world
- In VSCode settings, search for
Mount Wayland Sockerand uncheckDev > Containers: Mount Wayland Socket. For more information, see Github issue.
Related errors in logs:
Error response from daemon: create \\wsl.localhost\Ubuntu\mnt\wslg\runtime-dir\wayland-0: "\\\\wsl.localhost\\Ubuntu\\mnt\\wslg\\runtime-dir\\wayland-0" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute pathWSL use too much RAM or CPU. It can be useful to limit them on devices with a limited amount of RAM or CPU. To do that, follow the instructions below to limit to 2GB of RAM and 2 processors (you can adjust the numbers):
- Inside your user folder (
C:\Users\<UserName>), create a file.wslconfig. - To limit the resource usage of WSL2, in
.wslconfigadd the following:[wsl2] memory=2GB processors=2
-
If issue with permission and
/var/run/docker.sock, in WSL terminal, run those lines:sudo addgroup --system docker sudo adduser $USER docker newgrp docker # And something needs to be done so $USER always runs in group `docker` on the `Ubuntu` WSL sudo chown root:docker /var/run/docker.sock sudo chmod g+w /var/run/docker.sock
Additional resources:
-
If issue with
docker-credential-secretserviceandlibsecret-1.so.0: In distro terminal, run this line:sudo apt install libsecret-1-0
-
In distro terminal, to check if
buildxis installed correctly, run this line:docker buildx --help
-
If issue with
docker buildxnot found, run this command in your distro terminal (here we uselinuxfor Ubuntu):ln -sf "/mnt/c/Users/[WINDOWS_USER]/AppData/Local/Programs/Rancher Desktop/resources/resources/linux/bin/docker-buildx" ~/.docker/cli-plugins/docker-buildx
-
If issue
error getting credentials, run this command in your distro terminal:sudo apt install pass
-
If issue with
error getting credentials - err: docker-credential-desktop.exe resolves to executable in current directory (./docker-credential-desktop.exe)while downloading an image, delete the line withcredsStorefrom~/.docker/config.json. -
If issue with
Cannot autolaunch D-Bus without X11 $DISPLAYwhile building an image, run this command in your distro terminal:sudo apt install pass
-
If issue while permission flags are missing and user/group are set to
rootinside VSCode devcontainer, create a file/etc/wsl.configin distro with the following:[automount] enabled = true options = "metadata"
More information: here
Warning: Drawbacks about using files from another operating system here, here and here.