Configuring WSL2 for Seamless Compatibility with Rancher Desktop

Just out of curiosity, I downloaded and sat up Rancher Desktop on my laptop.

I daily use Docker and Docker compose on top of WSL2 using home made mechanism/tooling I would then see if Rancher Desktop fits well in this case and could help me.

In this (very short) article, we’ll go over the necessary steps to configure WSL2 Ubuntu virtual machines and Docker with Rancher Desktop.

If you want to get into Rancher Desktop in another way and discover how to install Skaffold, you can read this article.

The setup is quite straightforward. Follow the instructions provided in the official documentation to get Rancher Desktop up and running on your Windows machine. Rancher Desktop allows you to run Docker and Docker Compose seamlessly within a WSL2 environment.

During the setup process, I chose to install Moby to use Docker and Docker Compose.

After installing Rancher Desktop, you will need to ensure your virtual machine (VM) is connected to expose the Docker daemon and related commands. You can find detailed steps in the Rancher Desktop documentation under WSL Preferences. Don’t forget that in some cases, you may need to restart both WSL2 and Rancher Desktop for the changes to take effect.

When you start your Docker compose infrastructure and encounter an error like this:

1
Error saving credentials: error storing credentials - err: exit status 1,

You’ll need to configure Docker’s credential store. To resolve this issue, follow these steps:

  1. Inside your WSL2 VM, create or edit the ~/.docker/config.json file.
  2. Add the following content to the config.json file:
1
2
3
{                            
"credsStore": "wincred.exe"
}   

This configuration points to the docker-credential-wincred.exe binary and will resolve the credential storage problem when using Docker.

A common issue with Docker containers in Rancher Desktop is the lack of output in the console when running a container, such as with the command docker run hello-world. This issue is well-documented in this GitHub issue.

To view the container’s output in the console, you need to start your commands with the -i option. For example:

For instance:

1
docker run -i hello-world

This option tells Docker to attach to the container’s standard input, allowing you to see the output directly in your console.

I hope this article has been helpful for you, and you’re now ready to supercharge your development workflow with Rancher Desktop and Docker!