Local Development on a windows machine running docker containers

I typically work on a Mac, but a company I’m doing some work for gave their developers Windows machines to develop a php/mysql software application.

Typically when I’m developing locally, I can just mount my local code to the container code. So it’s super simple if I want to make changes.

Enter Windows sub filesystem for linux crap.
I’ve been trying for months to be able to write code in my IDE (phpstorm) and reload localhost and have it not take 30 seconds for a single page load.

I’m looking for any help on how I can make sure the devs can write code and immediately see that code change locally on their docker container from localhost.

Are you using Docker Desktop, or are you running Docker-CE inside a WSL2 distribution?

I am working with a customer laptop with Win10. Recent versions of Windows Subsystem for Linux have built-in support for UI applications and even allow using systemd. I run docker-ce and intellij ultimate (if I am not mistaken phpstorm is just a flavor of it) inside the WSL2 distribution. It works like a charm: systemd starts docker-ce when I start the distribution; when Intellij is started it is rendered as RDP Connection on the Windows host (runs perfectly fine on a 4k screen). Setting up Intellij inside WSL2 requires a bunch of packages to be installed (I can check the exact packages tomorrow)…

The customer also provides access to Docker Desktop for Windows and Intellij for Windows, but I prefer to work in a Linux environment.

Note: you could also map Windows folders into containers, though it is slow compared to directly working inside the WSL distribution. Or you could use IntelliJ on the Windows Host and have the code in the WSL distribution, but it’s no joy either: intellij is always re-indexing. I never got warm with their remote access methods or gateway either.

For me running docker-ce and intellij inside the wsl2 distribution provides the best experience.


If you want to use Intellij within the WSL2 distribution, you need these packages (at least on Ubuntu):

# general dependencies of intellij
sudo apt-get install -y libfontconfig1 libxrender1 libxtst6 libxi6
# JCEF Browser preview (required by Markdown and AsciiDoc Preview) depdendencies
sudo apt-get install -y xdg-utils libnss3 libnspr4 libgbm1 libasound2
sudo apt-get remove -y tilix --purge

Wait. I need more info, this sounds like something that might work. Yes phpstorm is built by intelij I think?

It’s so crazy that in a Mac I can just run docker desktop and have the local file system there with no issues.

Yes, running docker desktop.

I hate that I have to jump through 100 hoops to get this working.

You can do the same with Windows: docker run --rm -ti -v d:\winfolder:/test alpine ls /test will list the content of my d:\winfolder inside the alpine container. Give it a try. If you feel things are slower than they should be, you can still move everything inside a WSL2 distro.

What kind of Info are you looking for? I am perfectly happy with Intellij + docker-ce inside a WSL2 Ubuntu 22.04 distribution.

everything I’ve read points to the WSL being the problem of having the volume linked directly to my windows files.

This is what I’m referring to, when it’s in windows it is EXTREMELY SLOW, like 30 seconds to load a single page.

Ah, I just figured out how to do this. And you’re right works like a charm. using vscode on ubuntu 22. Works great.

With vscode it’s even simpler. Just install it on the host and use the wsl remote integration. I assume this is what you did :slight_smile: … I have no idea why jetbrains isn’t capable to create an identical experience for wsl integrations.

If you want to run intellij variations inside the WSL integration, I already posted the required dependencies in an earlier post. Of course, you would still need to install phpstorm for Linux inside the disto.

When working with different operating systems and facing challenges with code synchronization and performance in Docker containers. Ensure that Dockers volume sharing is correctly set up between the Mac and the Windows machine, allowing for effective code mounting. Verify the configuration to ensure the necessary directories are properly shared. Consider using Docker desktop for Mac, which provides a more optimized and seamless experience for running Docker containers on macOS.