Containers are not for Tupperware parties anymore; they are part of the IT world. Although Containers are not entirely mainstream yet, such companies as Docker have removed the traditional management burden that came with this technology. A small footprint, lightning fast speed and portability make them increasingly popular. But what are containers anyway?
Containers are essentially operating system sandboxes that are hosted on full operating systems. In the case of Windows containers, these are all hosted on Windows Server. Each container contains the minimal amount of resources, and any operating system-specific resources are gathered from the operating system “beneath” them. Windows containers have their own networking, file system and registry. When it needs the ability to interact with these systems, it will use the hosting operating system.
MORE: Docker Container: What Is It and Why It’s Important
There are two types of Windows containers; Windows Server and Hyper-V. A Windows Server container is the kind most associated with the traditional term of “container” like a Docker container. Windows Server containers behave similarly to containers in the Linux world. However, Hyper-V containers are essentially Windows Server containers running in a Hyper-V partition. These containers live in a lightweight Hyper-V virtual machine.
Here, we’re going to focus on Windows Server containers. There are a few ways to get started with Windows Server containers. You may choose a cloud service such as Azure Container Service. This prevents from having to either bring up physical hardware or even provision a new virtual machine to host a container on. Or, by using PowerShell, any machine running Windows Server 2016 can be configured to host containers.
Note: To create a Windows Server container host the operating system must be Windows Server 2016.
To learn more about the underlying container technology, let’s use PowerShell to bring up your first Windows Server container. Windows Server containers are built on Docker thus the first step is installing Docker. To do this, we’ll first need to install the Microsoft Docker provider. This is done through a PowerShell module. Fire up the PowerShell console on your Windows Server 2016 server and install it from the PowerShell Gallery.
Find-Module DockerMsftProvider | Install-Module
Once the module has been installed, we’ll install the latest version of Docker using Install-Package. Since the module previously downloaded is actually a PowerShellGet provider, we can specify this as the provider name to Install-Package. This allows Install-Package to find the Docker package.
Install-Package -Name docker -ProviderName DockerMsftProvider
Reboot the server. Once the server comes back up, you should be able to run the docker command. Below I’m merely checking the version of Docker to ensure the Windows service it created is running.
If no errors are returned, Docker is running. Then you need to install a Docker base image. This is required to run Windows Server containers. To do so, we’ll use the docker command again to pull down either the Windows Server Core or a Nano Server image from Docker Cloud. Below, you’ll see that I’m downloading the Windows Server Core image.
docker pull microsoft/windowsservercore
Optionally, the Install-ContainerImage PowerShell command can also be executed to provision this base image. Once installed, restart the Docker Windows service.
Restart-Service -Name Docker -Force
Once the base image is installed, you should now have a fully-functioning container host. You can now deploy containers at will using docker run. To do so entails specifying the name of the container and the image it will be created from.
docker run -it –name mycontainer windowsservercore
The container can be viewed with the docker command again using the images argument.
If successful, the mycontainer image, as well as the windowsservercore image, will be displayed. This will leave you with a fully-configured Windows Server container host running your very first Windows Server container.