(Not) Using Docker on Windows
Tags: docker, windows, linux
Published: 2021-07-03 12:56:34

## Introduction
![Windows Logo](https://www.asadodevculture.com/wp-content/uploads/2021/07/Windows-150x150.png)
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](https://www.asadodevculture.com/wp-content/uploads/2021/07/homepage-docker-logo-300x248.png)

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](https://www.asadodevculture.com/wp-content/uploads/2021/07/docker-loading.gif)

> 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](https://www.asadodevculture.com/wp-content/uploads/2021/07/docker-good.gif)

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](https://www.asadodevculture.com/)