DEV Community


Posted on

(Not) Using Docker on Windows


Windows Logo
I’m a Windows Boy. That’s it, I said it. My first computer was a DOS when I was 4. My father has programmed it to play a game if I write my name and press enter. At age 6 we installed Windows XP and a whole new world appeared in front of me.

I continued the normal path of Windows Vista (Why), Windows 7 (Thank G’d), Windows 8 (Mmmm), 8.1 (Ok, Ok, back to normal), and now Windows 10 (finally). I work with Windows Servers as well; Windows Server 2008 R2, 2012R2, 2016 and even Windows Server 2019.

I know Windows pretty well. I wrote C++ programs that interact with Windows Internals. Even wrote a small filter driver. I’ve installed and configured more Windowses than I could count.

So, following this introduction, you can see why my first thought was to install Docker on Windows.

Docker Logo

I asked another team, which had more practice using Docker, what they thought. They threw me away and told me I was being silly, “Docker should be only on Linux”. I asked why? there’s such a nice GUI for Windows..
Without a good explanation, I thought they were wrong and they just haven’t had any experience working on Docker for Windows. I went on installing Docker on Windows.

This is my story

The installation

First, you’ll need Windows Pro or Windows Server to install Docker. It won’t work on Windows Home. No problem, I thought, and updated my local version to Windows Pro. Then the installation went pretty smooth. The installation finished and a reboot was made.

Don’t they love reboots in Windows? It feels like there can be a good installation without a nice reboot at the end. Oh, your installation doesn’t require a reboot? That’s a petty…

After the reboot I opened up Docker and the nice GUI showed up. The Docker icon on the tray showed the “Loading and Unloading” animation for a few seconds. And it continued. And on and on and on. No worries I thought! Maybe another reboot will help? I preferred to ask my old good friend Google. They recommended installing WSL2. I had version 1 and I know 2 > 1 so 2 sounded like the correct way to go. After installing WSL2 (and rebooting) Docker started to work!

Docker Loading Logo

Looking backwards this was the first red flag. Too many things were “hard” at the installation phase. That shouldn’t happen.

The first run

After Docker started to work, everything else did it’s job correctly. Docker Build, Run, Load, Save and such worked as they should. But that only happened after Docker started running (obviously). Restarting Docker, or restarting Windows was nearly impossible to do straightforwardly. I almost always had to make 2-3 reboots until Docker was ready to work.

This was red flag #2, it’s like the G’d of Windows, Linux and Docker were shouting at me and I decided to ignore it.

The first bug

We have an app that sends packets over UDP. (Who hasn’t right?) The app worked perfectly outside Docker, but for some reason it didn’t work from inside a Docker container. After a few hours of debugging and logging and breaking and whatnot, we found out that Docker for Windows won’t pass any packet bigger than MTU from inside the container to the host. I mean, why? But fine, we changed the configuration so it would send packets of maximum MTU size and it fixed the issue.

This should have been the last red flag right? But no, we fixed the issue and everything else worked fine, when it worked, so why change anything?

The Last Straw

I wanted Docker to write all the logs to a file. A simple supported task. I read there was a simple configuration that you can tell Docker to route all stdout and stderr to a log file. You can even configure how many files and of what size they should be, pretty cool! I got stuck trying to understand where the files are. Really. Some said it was under %appdata% but nothing was there.

And then I found it. The log files are saved inside the Hyper-V image holding the Docker. WHAT. What should I do with that? How can I configure FileBeats (for example) to read that? That was it. I couldn’t find any more excuses to continue using Windows.

The salvation

I installed Linux. Ubuntu 20.04 in my case, but that doesn’t really matter. In a matter of 2-3 hours, I’ve changed my two VMs from Windows Server 2016 to Ubuntu 20.04, installed Docker, uploaded my images, configured the network and tested the App. And all that without making a single reboot!!!

Docker ftw

Docker worked as expected from the moment I installed it. The log files appeared and I could see them without making loops in the air. Docker started and restarted as expected whenever I needed. I saw the light.

You can tell me it is obvious that Docker works better on Linux. Even on Windows it runs on Linux (WSL). But I never heard a real reason why, or a painful experience to really understand why. This is why I wrote this post, to tell my story and warn others.

Please. For your own sake. don’t use Docker on Windows.

If you enjoyed reading this, you might enjoy other posts I've wrote! Check them here

Top comments (10)

stewart86 profile image
Stewart Wong

I have been running docker desktop on Windows 10 Home without a problem at all. Of cause running WSL 2 and Ubuntu 20.04 on WSL 2. And even when docker having updates, I did not need to restart my windows 10. files in WSL can be found when you put \$wsl in File Explorer or I simply enter the command explore.exe . to open File Explorer directly in the WSL directory.

If you have been developing with Windows for many years you should know that Microsoft has recently been focusing a lot on helping developers to use Windows for their development needs, and with WSL, this is a great achievement on their part.

I was at a dilemma a few months before when I was choosing between Linux laptop or Windows for my new development machine but eventually I choose Windows for it's current versatility.

javitolin profile image

Thanks for your input!
In my case it wasn't that easy. I don't know where I did wrong but it just wasn't that straight forward as with Linux. Furthermore, the community arround Docker for Linux is much (much) larger that for Windows.

cmiles74 profile image
Christopher Miles

A big part of the problem is Docker the company working so hard to hide much of Docker-on-Windows behind the GUI mentioned in the article. For instance, it's easy to think of switching to WSL2 as something of a non-change when it's just a switch in the GUI. But, of course, it really means running Docker in a Hyper-V container and that means when it writes to disk, it's writing to the VM's disk.

IMHO, the GUI and the Windows Docker implementation need to do a little more (redirect files but not bog down the host) or do a lot less (force us all to understand the compromises).

javitolin profile image

The GUI really "dumbs down" Docker. At first I was pleased to see a GUI instead of the CLI. But after a few hours working with the Linux Docker's CLI I'm actually pretty comfortable with it and I can use all of it's functionality.

mikeyglitz profile image
mikeyGlitz • Edited

First, you’ll need Windows Pro or Windows Server to install Docker.

You can circumvent this with WSL 2

As much as I like Windows, I enjoy the Docker experience so much more on Mac

mikeyglitz profile image
mikeyGlitz • Edited

A friend of mine had shared this guide with me a while back. I found it super useful for enhancing the performance of docker on WSL.
I've also switched to using Alpine as my primary Linux distro because it's a lot more lightweight than Debian/Ubuntu and resources are an issue on my laptop.

javitolin profile image

I think your link is broken

Thread Thread
mikeyglitz profile image

Fixed it

javitolin profile image

Never worked on a Mac. Hope to work on one soon!

danidavid profile image

Thanks for telling ❤️