Skip to content

Instantly share code, notes, and snippets.

@aifrak
Last active August 2, 2025 19:08
Show Gist options
  • Select an option

  • Save aifrak/7168ca81723425692a7c0d66138e2e67 to your computer and use it in GitHub Desktop.

Select an option

Save aifrak/7168ca81723425692a7c0d66138e2e67 to your computer and use it in GitHub Desktop.
Setup scoop + WSL2 + Ubuntu + Rancher Desktop + VSCode

Setup scoop + WSL2 + Ubuntu + Rancher Desktop + VSCode

Setup

  1. In Powershell, install scoop:
    Set-ExecutionPolicy RemoteSigned -Scope CurrentUser # Optional: Needed to run a remote script the first time
    irm get.scoop.sh | iex
  2. In Powershell, install WSL2:
    wsl --install
  3. In Powershell, install Rancher-Desktop:
    scoop install rancher-desktop
  4. Read carefully and follow the post-install instructions from the terminal.
  5. Open Rancher Desktop
  6. On welcome screen of Rancher-Desktop, check dockerd (moby) (source).
  7. Uncheck Kubernetes.
  8. Click on "Accept".
  9. In Rancher Desktop, on the home screen uncheck Check for updates automatically.
  10. In Rancher Desktop, File > Preferences > WSL > Choose your distro (for example Ubuntu) > click on "Apply".
  11. In distro terminal, to check if Docker is installed correctly, run this line:
    docker ps
  12. In distro terminal, because of some issues explained in the Troubleshooting section, run the following:
    sudo apt install pass libsecret-1-0
  13. In distro terminal, to check is Docker can run a container correctly, run this line:
    docker run -it hello-world
  14. In VSCode settings, search for Mount Wayland Socker and uncheck Dev > 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 path

How to limit resources usage

WSL 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):

  1. Inside your user folder (C:\Users\<UserName>), create a file .wslconfig.
  2. To limit the resource usage of WSL2, in .wslconfig add the following:
    [wsl2]
    memory=2GB
    processors=2
    

Troubleshooting

  1. 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:

  2. If issue with docker-credential-secretservice and libsecret-1.so.0: In distro terminal, run this line:

    sudo apt install libsecret-1-0
  3. In distro terminal, to check if buildx is installed correctly, run this line:

    docker buildx --help
  4. If issue with docker buildx not found, run this command in your distro terminal (here we use linux for Ubuntu):

    ln -sf "/mnt/c/Users/[WINDOWS_USER]/AppData/Local/Programs/Rancher Desktop/resources/resources/linux/bin/docker-buildx" ~/.docker/cli-plugins/docker-buildx
  5. If issue error getting credentials, run this command in your distro terminal:

    sudo apt install pass
  6. 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 with credsStore from ~/.docker/config.json.

  7. If issue with Cannot autolaunch D-Bus without X11 $DISPLAY while building an image, run this command in your distro terminal:

    sudo apt install pass
  8. If issue while permission flags are missing and user/group are set to root inside VSCode devcontainer, create a file /etc/wsl.config in 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment