I'm transitioning from Linux to Windows and want to set up WSL2 to work with Docker and IntelliJ. I've already installed WSL2 with necessary tools like Java, Maven, and Angular inside it. My team uses Docker Desktop on macOS, so I installed it on Windows with WSL2 and Ubuntu integration. However, I'm running into some issues. First, I want to limit Docker's resource usage to avoid excessive lag in Windows. I'm considering whether it's better to use Docker directly in WSL2 instead of Docker Desktop. Additionally, I've got IntelliJ installed on Windows, and I'm trying to point it to the Java SDK in WSL2. Yet, I keep getting an error about not finding a compatible JDK. Should I install a separate JDK for Windows, or is there a way to make it work with the one in WSL?
5 Answers
Installing Docker directly in WSL2 is usually the best option since it gives you better performance compared to Docker Desktop. Also, IntelliJ can be configured to use the Java inside the container if you set it up right.
For the cleanest setup, consider separating your concerns. Install Docker Engine inside WSL2 to avoid the quirks of Docker Desktop. For IntelliJ, it's generally easier if you install a Windows JDK and set that as your Project SDK. You can still run everything else like Maven and Docker commands directly in WSL2.
I encountered a similar setup where mapping a drive between Windows and WSL helped a lot. Just type 'explorer.exe' in your WSL terminal, and it opens the WSL path in Windows Explorer. You can map it to a drive letter for easy access to your files.
For your RAM issue, I'd recommend skipping Docker Desktop completely and install Docker Engine natively in WSL2. This way, you avoid the extra overhead from Docker Desktop's VM layer. It lets you control memory limits directly in WSL. As for IntelliJ, it sometimes has trouble with WSL paths for the JDK. You have two choices: install the JDK for Windows and point IntelliJ to that, or use WSL's built-in JDK path under IntelliJ's settings. The Windows JDK route tends to be simpler and less frustrating overall.
From what I've seen, running Docker natively in WSL2 is a solid choice, especially to prevent RAM issues. For IntelliJ, using a Windows JDK is usually the way to go. It makes running tests simpler and avoids a lot of path resolution headaches when working inside WSL.

Absolutely! Docker Desktop has its quirks and can lose WSL integration at times, which can be a hassle to fix.