I’m a solution architect and senior web developer. I’ve been using Docker on Ubuntu for 3 years and for applications with multiple services — for example nginx, php-fpm, mysql, ElasticSearch, Redis, logstash, Kibana, node — there is no better way to work. Docker has been a Godsend. Modeling your prod environment to a tee and running it on a reasonably priced and powered laptop is the holy grail.
Now I’ve started at a new company and they use Windows. Not realizing I would find so many problems, I started by doing what I’ve been doing, getting all the specs to their production environment and started building Dockerfiles and docker-compose. I managed to transition pretty well to Windows and Powershell. I followed theDocker integration for WSL2, but still have to use Powershell or cmd for certain things.
Here’s the problem. Files don’t update properly or consistently. My projects have 100,000 files when you get all the node modules, vendor libraries, images and css. Sometimes the application just dies because the log file suddenly can’t be found. Or composer install on the Windows host works fine and created an auto loader with 6,000 lines, but inside the container it contains only 4,500 lines. After all the work of setting up the environment in Docker - it’s unusable for development and I wasted nearly three weeks tinkering and experimenting and searching on the docker forums and stack overflow for similar issues, workarounds and bugs.
I did find some open issues on Docker for Windows. My experience with Docker on MacOS is similar and although large projects work on Mac, they’re so slow they’re also unusable. Talking 1.5 minute page loads, when on Ubuntu 20 with the same setup 1 second page loads for the same app.
I’m just curious- am I off on uncharted territory? Am I doing it wrong? Or is it just a state of reality that Docker is for Linux and everywhere else is just a close approximation? I am trying to convince my new IT guy to let me install ubuntu but I don’t know if it’s gonna happen... falling back to using xampp feels like I’m going back in time 10 years.
I’ve had some issues with the hundreds of files caused due to node also. The fix was to assist the write out having in docker to not write in the background due to mounting and instead just write immediately. This was using dev containers in vscode.
I never had an issue when using pure docker from the powershell command line with Linux or windows containers.
Are you using wsl or windows containers?
It’s unclear to me which part of this is slow. Is your machine under spec? 32GB ram is a minimum here. We have 10+ devs using docker for windows and I’ve never seen the issues you’re talking about.
Docker on Windows doesn’t perform well even if you run it through wsl2. It’s just not there yet. The performance of heavy file operations is terrible. Better to stay with Linux if you have a choice, at least this is what I did. I have tried it on a Mac too – it is better than Windows, but still slower than Linux.
While I was still on Windows, I have realized that if you are on wsl2 you must keep the project files *inside* the wsl2 to actually get some performance gain.
> Or is it just a state of reality that Docker is for Linux and everywhere else is just a close approximation
It’s somewhat a state of reality, IMO. You have to think about how Docker works- it’s really just process isolation built on top of Linux features supporting that. At that level of operation, feature implementation is very OS (kernel) specific. So it’s not that Windows doesn’t have something like that (FreeBSD or other Unix-Likes, for that matter, Jails for instance), but at that level, the implementations are different. Getting something working identically is going to be more difficult because you’ll run into fundamental architectural differences in the OS- that’s why Docker on Windows doesn’t work quite the same as Docker on Linux.
Now, as for it on WSL2, I haven’t tried it on WSL2 myself, but I’m a little surprised you have issues there, at least from how I understand WSL2 was being implemented. Personally, I run my Docker containers on a Ubuntu Server VM in Hyper-V. The question here might be what are you dev’ing for, like they are Windows deployed internally but apps you are developing live on Linux servers hosted on Apache of nginix anyway?
You could maybe go the route I mentioned, if that’s the case- Linux in VM, locked it to a local network only on your machine, and use Docker as you are used to…it’d only be a tiny bit more hassle to move data in and out of shared folders visible to the guest and therefore the Docker containers. I say that though as an IT guy that thinks it’d be pretty trivial to do. Doesn’t seem like it should be that different than WSL2 though, which is why I am surprised it isn’t working unless MS did something that makes things Docker relies on not work properly in WSL2.
This has been my exact experience working with Windows legacy apps. They’re bloated pieces of software that don’t work well in a container environment. There is a way forward though but requires apps to run as .Net Core 3.1 apps at a minimum. Since most of the apps have been transitioned over to .Net Core I have not had many issues. Sounds like a good refactor/rewrite is in order. I’ve been able to use Alpine images successfully with the .Net Core setup and haven’t had nearly as many issues. If you’re not using that I would highly recommend you do.
I agree with this. Docker for windows is complete trash, though, that’s not docker’s fault… windows is just horrible for this type of thing (and most other things). Although we are mostly node and golang now, we still have an old ass legacy app on asp framework. Managed to get it containerized and running on kubernetes, but what a horrible experience. Can’t wait until we get that legacy stuff rewritten.
Check to make sure that docker for windows is getting full access to as much CPU and Memory as you can. Sometimes native Linux users don’t realize that the Docker for Windows install usually has a pretty conservative performance cap on the VM or hypervisor manager resource reservations.
Docker was never intended to fully run on Windows. It’s a Linux citizen at heart. The fact that there is a Windows port is just more or less a bonus/curiosity.
All those problems are solvable the main issue with docker for windows is network performance is still very immature. Missing files sounds like an environmental problem have been working with docker on windowd since it came out, have an enterprise legacy framework45 app that is a monster running in it. Never had any issues with missing files even after generations of rebuilding images to patch them (olease don’t confuse this post as advocating d4w, its infuriating.)
> My experience with Docker on MacOS is similar and although large projects work on Mac, they’re so slow they’re also unusable.
That’s interesting. As I understand it, Docker on Mac still uses a full-fat virtual machine under the hood. So, whatever issues Windows 10 has, they are different to the Mac’s issues, since the underlying way Docker runs is very different.
Minikube. It works great with d
Windows. And as an added bonus you don’t have to use docker compose anymore. So you can get far better control and customizable. It’s a bit of a leap but if you have the images made already it’s a very easy swap. And using helm makes it even easier.
What? We have been on windows docker for almost 3 yrs now(mvc app with IIS),rock solid
Why would you use windows if it’s mostly node modules? And why would not you pack it when you deploy?
Docker for Windows is simply not edge ready.. irrespective of what MS says. Their whole implementation of networking a.k.a HNS is the stuff of nightmares. You put enough load and stuff breaks left and right . Things have gotten so worse, we are now moving all workoads to RHEL with Dotnet 5.
If you expected same Linux experience on Windows, with Docker, you have a problem about your expectations.
Docker on windows is a work around, and you need to understand these differences and accept that.
Run a another kernel has a cost, anyway it’s under a virtual machine.
If you know these architecture, you may be blessed to these work.
This effort to run Docker on windows, running Linux Containers it’s not common here.
I work for a Microsoft Partner.
I run Debian in a Hyper-V guest on my workstation and have docker installed there. Then I use sftp plugin for VsCode to edit files. Works smooth. No one can fuss about me not using Windows.
Windows Terminal is excellent and the best you’ll get in Windows for approximating the Linux terminal.
A bit more setup but worth it down the line. Full benefits of docker on Windows.
Yupe I gave up and just setup an Ubuntu machine and all works as expected.
All those wsl2 suggestions above sound very interesting and maybe I’ll give em a try soon…
#following
On MacOS I noticed a big speed up when switching to [docker-sync](https://docker-sync.readthedocs.io/en/latest/getting-started/installation.html) for all the big volumes. But it introduces new problems and sometimes seems to get stuck and dont sync anymore.
I have 4 questions for you.
I use Docker Desktop here on Windows 10 and it’s been working great for large projects (even ones with a node_modules directory with enough gravitational pull to move the universe). Great as in, code gets reloaded in 50-300ms depending on what tech stack I’m using. This is on a 6 year old workstation too.
1. Are you using WSL 2?
2. Do you have Docker Desktop configured to use WSL 2?
3. Is your source code living inside of WSL 2’s file system, not being accessed through /mnt/c?
4. Have you tried disabling Windows Defender if all of the above is true?
If you’re curious, I have a video of how I set up my dev environment on Windows. It includes WSL 2 / Docker (both demo’ing it and setting everything up). It includes a bunch of other tools too but you can use the time stamps to jump to the Docker specific bits: https://nickjanetakis.com/blog/a-linux-dev-environment-on-windows-with-wsl-2-docker-desktop-and-more
Seriously… What did you expect?
Docker was and is developed on completley different architectures than Windows. And even with WSL it is not the way it is intended to be used.
MS is really giving their best to minimize friction here and there but they simply cannot compete with native solutions.
Possible suggestions:
1. Stick with WSL2.
1. Mount volumes in the WSL2 file space.
WSL2 Linux is much the same as using a VM but it’s more tightly integrated. However NTFS is slower and more limited than Linux drive formats so don’t use them.
You can access WSL2 drives at `\\wsl$\Ubuntu\` (or whatever your distro is called) or use VS Code remote plugins.