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.
1 Install & configure Rancher Desktop
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.
2 Configure Docker Credential Store
When you start your Docker compose infrastructure and encounter an error like this:
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:
- Inside your WSL2 VM, create or edit the
~/.docker/config.json
file. - Add the following content to the
config.json
file:
{
"credsStore": "wincred.exe"
}
This configuration points to the docker-credential-wincred.exe
binary and will resolve the credential storage problem when using Docker.
3 Get container’s output in the console
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:
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.
4 Conclusion
I hope this article has been helpful for you, and you’re now ready to supercharge your development workflow with Rancher Desktop and Docker!