Docker is one of a few container management platforms available across operating systems such as Windows, Linux or MacOS. It manages the build, deployment and tear-down of containers and eliminates the "works on my machine" problem by essentially creating an abstraction layer between your application and the underlying operating system while at the same time describing the application including the operating system as code, the so-called Dockerfile.
If you want to learn more about Docker, check out the official website.
Install Docker on Windows 10
Docker works cross-platform and such supports execution on a Windows host, including Windows 10 (Pro or Enterprise). This makes Windows 10 a perfect development environment for Docker use-cases. On top of this, Windows is also the only platform, for now at least, that can run Windows and Linux based containers. This is because containers share the hosts kernel, so Windows can run Windows containers and, thanks to nested virtualisation in Hyper-V, we can also run Linux containers inside of a very small Linux VM, that is 100 percent managed by Docker. Right now, however we must decide if we want Linux or Windows containers, we cannot run both at the same time.
As a prerequisite to install Docker you need to enable Hyper-V on your machine. If you do not want to use Hyper-V you can also use VirtualBox.
To install Docker on Windows 10 we have two options.
- Download the source
- Use the Chocolatey package management provider
I prefer the latter method, but just be aware, this is not a package maintained by Docker, plus you might need to provide Chocolatey with the "--ignore-checksums" parameter.
Depending on the way you installed Docker you either need to restart or open up a new PowerShell. Run "docker --version" to see if your PATH variable has been configured correctly.
By default, Docker is configured to run Linux containers and to support these Docker will create a small Hyper-V VM on your machine.
You will not be able to connect to this VM, the only way to interact with Docker is via its command line.
Our first Windows Docker container
In our taskbar, we will now also find a new icon in the form of a whale carrying tiny containers. This is Docker.
From here you can switch Docker over to "Windows containers", follow any prompts, if any, and wait for the Docker whale to be done switching over to Windows containers.
In PowerShell execute the following to download and run your first Windows based container:
"docker pull microsoft/nanoserver"
This will download a Windows Server 2016 Nano Server based container image from the public Docker Hub container registry.
If you are on the Windows Insider program, give this a go, this is the new, even smaller Nano Server image. Compressed it is only 78.5MB in size.
"docker run -it microsoft/nanoserver powershell"
from your PowerShell. Docker will create a new container and attach your current shell in an interactive session with an input command line / TTY ("-it" parameter) to the process specified on the command line, in our case "powershell."
If you are unfamiliar with Nano Server, browse around, try a few things and familiarize yourself with it.
In a separate PowerShell, enter "docker ps" to see your currently running containers and get some information about them. To exit the container, simply enter "exit" until you end up in your local session