I'm transitioning from Linux to Windows and want to set up WSL2 effectively. I've already installed Java, Maven, and Angular in WSL2 and integrated Docker Desktop with WSL2 and Ubuntu support. However, I encounter a couple of issues: firstly, Docker Desktop is overly resource-intensive and really impacts my machine's performance. I'm thinking about either using Docker natively in WSL2 or exploring other alternatives. Secondly, I have IntelliJ installed on Windows and the project repositories are in the WSL2 path, but I'm facing a "Failed to find compatible JDK" error when running unit tests. Should I install Java on Windows as well, or is there a better approach?
5 Answers
For a cleaner setup, avoid using Docker Desktop and install Docker directly in WSL2. This eliminates problems with RAM usage and keeps everything in the same environment. For IntelliJ, it's usually best to use a Windows JDK for smooth operation. That way, you avoid JDK resolution issues inside WSL. You can maintain your workflows in WSL for Maven and Docker without any trouble.
Honestly, the best setup I've seen is to run Docker natively in WSL2 and completely skip Docker Desktop if possible. It saves you a lot of headaches. For IntelliJ, you will likely need to install a JDK on Windows to avoid the path recognition issues with WSL. Although it's not the pure Linux experience, it’s practically hassle-free for daily development.
I have a similar setup and I found it helpful to create a mapped drive. You can run `explorer.exe` from WSL to open the Windows Explorer right where your WSL files are, making it easy to manage files. As for Docker, I'd highly recommend sticking to Docker Engine in WSL2 since it creates fewer issues with RAM and performance. For IntelliJ, using a Windows JDK is often the most reliable option for running tests from the IDE.
You might want to skip Docker Desktop altogether and go for Docker Engine just in WSL2. This setup lets you manage memory and resource limits the way you prefer. Regarding IntelliJ, the reason for the "Failed to find compatible JDK" error is because it's not good at finding JDKs in WSL paths from Windows. You can either install a JDK on Windows and point IntelliJ to it or use WSL settings in IntelliJ to link to the JDK within WSL, which tends to be a bit less of a headache if you go the Windows JDK route.
It's definitely more efficient to install Docker directly in WSL2 rather than using Docker Desktop. This way, you get a more seamless Linux experience without the added overhead. For IntelliJ, you can configure it to use Java inside a Docker container, which can solve some of your issues. Just be aware that IntelliJ on Windows sometimes has trouble recognizing WSL paths, especially for the JDK. So, installing JDK in Windows could be the simplest way to avoid those errors.

Related Questions
How To Get Your Domain Unblocked From Facebook
How To Find A String In a Directory of Files Using Linux