Containers on Windows 10
This is part 1 of what will most likely be a series (unless I get totally hacked off with containers like I am right now). Part of the series will be about getting containers up and running on a Windows 10 box to run a Windows based container. Then I will progress onto Windows Server 2016 and get the same configured container to run on that and hopefully discover some kind of work flow for developers along the way. The end game is to develop a website using Visual Studio 2015, test on Nano Server running IIS and deploy using Server 2016.
Apart from Windows 10 professional or Enterprise, you need to be sure you are running at least the Anniversary Update (1607); to check this go to a command line and type:- winver
I am running 1607 build 14393.187 (22nd September 2016)
To get containers installed, you need to enable the feature. This can either be done using PowerShell or the UI. Here is the PowerShell:-
Enable-WindowsOptionalFeature -Online -FeatureName containers -All
Then as Windows 10 will only support Hyper-V containers, enable that feature as well:-
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
Then restart the computer
As of Docker version 1.12 there is an option to download Docker for Windows, however to natively run Windows containers instead of using MobyLinux as a middle ware virtual machine, opt to install the beta version which can be found here:- https://docs.docker.com/docker-for-windows/
Switch to Windows Containers
Now you can get the version of Docker and it should show that both host and client are running windows.
According to this link you can run both Server Core and Nano Server on a Windows 10 Pro machine within a Hyper-V container.
The best way to get Nano Server is from the Docker hub at:- https://hub.docker.com/r/microsoft/nanoserver/
In your command line or PowerShell screen use:-
docker pull microsoft/nanoserver
It will take a while to download if it has not already been cached on your host machine.
List the images
To list the images you have on your host use the command:-
Run Nano Server
This can be achieved simply by using the docker run command; however if you want to run it interactively you can append the –it flag and get into a command line like this:-
docker run –it microsoft/nanoserver cmd
Once it starts up you will be in the command line of the container; you can check this by using the hostname command.
You can get out of this container by typing exit and it will get you back to your host machine. Once there use the command docker ps and it will list all running containers and you will see there are none running now. You can however use the switch –a to get all containers in both running and stopped state.
As you can see I have a lot of containers, but thats ok I can delete them all by iterating through them all and remove using the rm command like this:-
FOR /f "tokens=*" %i IN ('docker ps -a -q') DO docker rm %i
A nice clean slate to start again.