Docker for Windows

Going native

Docker for Windows and Mac were recently released as betas. You can enroll for early access here
Docker has taken one step further towards making Docker feel like a truly native app. The installation is now just a “one-clicker” (or drag-and-drop in the Mac case) without the need for VirtualBox.

It is currently only available for Windows 10 with Hyper-V.

D4Winstall

After installation the Docker Engine is running with the whale icon in the system tray…
D4Wtray

…and using Docker from the command line is all set:
D4Wcli

Replacing VirtualBox

The default hypervisor is now Microsoft’s pre-bundled Hyper-V with the intention to relief the user of having to install a third-party virtualizer such as VirtualBox. Another benefit is that users don’t really have to think about the extra layer that the virtual machine adds which aligns better with the user experience running Docker on a Linux machine.

The new stuff

  • The VM used for running the Docker Engine is now an Alpine based image which is superfast to boot.
  • Volume mounting and file system integration with the VM and container has improved which makes developing an application in a container much smoother.
  • The IP of the container can now be resolved by using http://docker instead of http://<IP-of-the-container>
  • You can now use ARM containers to create app for targeting e.g. Raspberry Pi.

Example of a .NET Core Web App in a Docker container

Let’s create a super simple ASP.NET Web app serving static files and put it in a container.
The code is located in a volume in the host which is mounted in the container. This way, changes to the code can be picked up by Docker and reflected in the app running in the container.
The Dockerfile:

The docker-compose file

The wwwroot in which the html files are located is mounted an thus changes here are reflected in the container.
The Startup.cs class is just:

To launch the app just type
docker-compose up
And navigate to http://docker:5004/Hello.html:
You can now do changes do the html-files on the Windows machine and the changes will be reflected in the running app:
HelloFromDockerWindows
The nice thing here is that everything except for the actual code is contained inside the container such as the CoreCLR, .NET Core libraries etc.

Limitations

Currently Docker for Windows and Mac only support running one Docker host but this will change in the future.
Using another virtualizer than Hyper-V such as VirtualBox is still possible but you will have to turn off Hyper-V as it can’t coexist with VirtualBox.

Source code

The code for the application is available here.

This Post Has 2 Comments

  1. Nice! Looking forward to try this out :)

    You say “Currently Docker for Windows and Mac only support running one Docker host but this will change in the future.” – does this limit the number of containers I can spin up? E.g., would it be possible to have one container like the one in the example, and another one serving a json api, and spin them up together with docker-compose? (Total docker newbie here…)

    1. Thanks Tomas!
      The single Docker host limitation only means that it’s not possible to create a (local) Docker swarm consisting of more than one node (docker host VM). However, you can still use docker-machine to do this.

Leave a Reply

Close Menu