Testing Windows Server 2016 Containers

Windows Server 2016 presents a new feature that already exists in the Linux world – Windows Containers. You can read about them here – Windows Containers on Windows Server

Suppose I want to deploy a Windows Server container with the SQL Server 2014 Express – what steps should one take to do it?

Firstly, we should find the corresponding container (which is a ~fully ready for deployment application with all required OS links, files and e.t.c) so we go to https://hub.docker.com/u/microsoft/

23

Once I see the container I’m going to install I can click on it and see how it can be deployed:24

The command for downloading and registering the container is the “Docker Pull Command” (docker pull microsoft/mssql-server-2014-express-windows) and the command for installing container is docker run.

If this is the first container to be deployed on the server we need to install the docker server and docker client – here’s how:

1) Install Containers Windows feature:
Install-WindowsFeature containers

01

2) Restart the computer

3) Install Docker server (daemon) and client

3a) Create a folder in the C:\Program Files\ for docker files – either in the Explorer or by
New-Item -Type Directory -Path ‘C:\Program Files\docker\

02

3b) Download Docker server (daemon)
Invoke-WebRequest https://aka.ms/tp5/b/dockerd -OutFile $env:ProgramFiles\docker\dockerd.exe -UseBasicParsing 0304

3c) Download Docker client
  Invoke-WebRequest https://aka.ms/tp5/b/docker -OutFile $env:ProgramFiles\docker\docker.exe -UseBasicParsing

06

3d) Add the Docker directory to the system path – again either in the GUI or by running
[Environment]::SetEnvironmentVariable(“Path”, $env:Path + “;C:\Program Files\Docker”, [EnvironmentVariableTarget]::Machine)

07

3f) Register Docker daemon as a service:
dockerd –register-service

08

If you see the same error as the one above please restart a server and try again:
09

3e) Start the docker service – NOT dockerD !
Start-Service docker

10

Before deploying a container a base container image should be installed first: a base container image (or template) is the OS image upon which the additional application layer – the container itself – will be deployed. Currently MS offers only the two base container images – Windows Core and Windows Nano.
Since in the SQL Server Express container Short Description field we see
“Microsoft SQL Server 2014 Express installed in Windows Server Core based containers.”
the next step will be installing Windows Server 2016 Core base Container image.

4a) Install container image package provider (~the app that rules the container images)

Install-PackageProvider ContainerImage -Force

11

4b) Install Windows Server 2016 Core base Container image
Install-ContainerImage -Name WindowsServerCore 12

13

14

4c) Restart the docker service after the base image instakkation – either in the Services or by running
Restart-Service docker

4f) Make sure the newly-downloaded image is listed in the docker images‘s output:

   docker images

15

As you can see it is NOT listed: the cure is to restart the docker service:
16

17

4e) Add this image the tag “Latest”:

docker tag windowsservercore:10.0.14300.1000 windowsservercore:latest

18

5) At this stage we can proceed to installing the microsoft/mssql-server-2014-express-windows Windows Server container by running the command specified on the container’s page:

docker pull microsoft/mssql-server-2014-express-windows

25

27

28-Error

The result: downloading has completed successfully but the container has failed to register in the OS. In this case we can try to install the lates updates for Windows Server 2016 TP5 (as was suggested on the technet forum) and try again:

29-GoodDone.

6) The final step – running the container and testing SQl Server 2014 Express.

Again, the command for running the container is displayed on the container’s page:

“You can run the container with the following command:”

docker run -p 1433:1433 –env sa_password=<YOUR SA PASSWORD> microsoft/mssql-server-2014-express-windows

I will use the following command:

docker run -p 1433:1433 –env sa_password=P@ssw0rd microsoft/mssql-server-2014-express-windows

-p 1433:1433 means the container host‘s port 1433 will be redirected to the container’s port 1433.

30Pic.6.1

33

35

It works!

Nevertheless, there’s one strangeness you may have noticed on the Pic.6.1 – after pressing the Enter the OS command prompt has not appeard – as if the command is still running. Yes, the switch -d (run as a background service) had not been used but I was expecting to see the command to complete – either successfully or not. I don’t know if it by design or not, but after closing this Power Shell window SQL Server 2014 Express is stll working. We can also make sure the container is working by running the following command:

  docker ps

36

Advertisements
%d bloggers like this: