Native Containers on Windows 2016Until very recently you only had one OS option for running Docker containers - Linux. You couldn't run containers natively on Mac or Windows.
Docker do a great job of allowing you to develop and test Linux Docker containers on Windows or Mac inside the Boot2Docker VM, but the Docker client and daemon are still running on a Linux OS within your Boot2Docker VM.
Now there's another option (at least in preview) - the Docker client and daemon will run natively on Windows 2016 Server and you can run Windows Docker containers there.
This post takes you through a worked example of how to port an application to run in a native Windows Container. I'll use our application, Force12, as our example.
Part 1 covers how to set up an Azure Windows 2016 host VM to try out Windows Containers.
Windows Docker Containers?First off, let's be clear that Windows 2016 only runs Windows Docker containers natively. You can't run your existing Linux Docker containers natively on Windows and you'll never be able to. Let it go.
This article is about creating new Windows containers with Windows-compatible content and running them on Windows.
PowerShell Containers Vs Docker ContainersTo confuse things further, Windows 2016 supports both Docker containers and PowerShell containers. These are not interchangeable either. If you create a container using Docker you have to manage it using Docker. If you create a container using the new PowerShell container commands you have to manage it using PowerShell commands.
This article is about creating, running and managing Docker containers on Windows.
We can worry about PowerShell containers another time.
Aside - How does this all work?Just for background info, Microsoft formed a team of developers to work with Docker on stuff including adding a shim into the Docker daemon to create/start etc.. containers on Windows. The shim is open source and you can see it in the Docker repo on github. The shim is written in Go and sits on top of the WinAPIs, using familiar WinAPI calls like LoadLibrary to drive the WinOS container functionality in a Docker-like way.
In part 1, we start with simply creating a Windows 2016 machine to play with.
Step 1 - Set up an Azure accountVisit https://azure.microsoft.com/en-gb/pricing/free-trial/ and follow the instructions
Step 2 - Set up a Windows 2016 Server Host VM
To create a test VM
- Log into the Azure portal https://portal.azure.com using your account
- Select "Virtual Machines" in the left hand navigation
- Click the + Add button to create a new VM
- Type "containers" in the search box
- Select "Windows Server 2016 Core with Containers Tech Preview 4" from the returned options
- Select Optional Configuration > Endpoints >
- enter an HTTP endpoint with a private and public port of 80. Now click OK in both tiles
At this point brace yourself. This Windows 2016 Server variant DOES NOT COME WITH A GUI. This really is preview stuff. You're going to have to use the command prompt and PowerShell to start with. Don't panic ;-) We'll step through it in Part 2.