Skip to content

Windows Support

Nuno edited this page Apr 11, 2019 · 9 revisions

Docker in Windows Architecture

To understand why docker-mocha is not supported in windows, we first must understand how the docker architecture in windows is implemented. The architecture is displayed in the following image:

Docker In Windows Architecture

Figure 1: Docker In Windows Architecture

While in Linux, Docker works on top of the operating system, the same does not happen for windows. Docker in windows is not natively supported. The architecture represented in figure 1 is mounted when the installation of the Docker is conducted. It will create a Linux Virtual Machine using Hyper-V called MobyLinuxVM. It is inside this virtual machine that the docker engine is running, and so, it is inside this machine that the containers will be executed.

In order to communicate with the Host and vice-versa, it is created an additional virtual switch with two virtual interfaces, one attached to the Windows 10 host (defaultNAT with IP 10.0.75.1) and another attached to the MobyLinuxVM (hvint0 with IP 10.0.75.2). This way it is possible to interact with the docker inside the virtual machine.

For the common user, this architecture information is useless. The docker commands work properly either in CMD or PowerShell, despite the fact that they are actually interacting with MobyLinuxVM. It is as if docker in windows was actually a remote shell (ssh) to another machine.

Docker-Mocha implementation

Why does this architecture affect docker-mocha?

Docker-mocha uses simple docker commands in order to manage the states and containers. However, when checking if a service is online it cannot rely on docker to get that information. For that, docker-mocha uses netcat with the container IP address and specified port.

Given the containers are running in isolated networks, they all have a different assigned IP. These IP's are "pingable" by default on Linux given the Docker implementation on Linux. However, the same does not happen in windows. These IP's are only known by MobyLinuxVM. So, when using netcat in Windows host with the given addresses, the netcat script will run indefinitely.

This is a issue that currently exists in docker. Unfortunately, while docker networks are not properly implemented in windows, docker-mocha cannot have support for windows.

Workaround

There is a workaround that makes docker-mocha work in windows. By updating the windows host route tables with the containers sub-network

Example

route ADD /P 172.20.0.0 MASK 255.255.0.0 10.0.75.2

The first IP address represents the sub-network where the container is running. The second IP address represents the sub-net mask. The third IP address represents the IP address of hvint0 interface of the MobyLinuxVM. Which is the interface that knows the routes to all the docker networks and respective containers. It is also able to communicate with the windows 10 host.

Unfortunately this is a highly unreliable method for several reasons:

  1. We aim to keep a level of isolation for docker-mocha, so altering the routes of the host machine is a bad practice and not recommended.
  2. Administrator permissions are required in order to alter the routing table of the host machine.
  3. It is practically impossible to obtain the hvint0 interface address. This address is known exclusively by MobyLinuxVM which is inaccessible when using common and reliable methods.
  4. Permanently using the hard-coded hvint0 address (10.0.75.2) is a very bad practice. Not only we should avoid using hard-coded values, but also using this address is highly unreliable. The interface address might change in the future or it can already be a totally different address from the instant docker was installed in windows
Clone this wiki locally