Back to Home

Windocks - SQL Server and .NET containers on Windows Server 2012 R2 with docker api support / RUVDS.com blog

docker · windocks · virtualization · administration

Windocks - SQL Server and .NET containers on Windows Server 2012 R2 with docker api support



    Hello, dear readers of Habr. Today we’ll talk about Windocks, a product of the company of the same name, positioning itself as the first docker engine for Windows. While Microsoft customers expect a new version of Windows Server, namely Windows Server 2016 ( Technical Preview 5 is available at the time of writing ) with native support for docker containers , the creators of windocks tried to provide docker containers for the current generation of windows server systems.

    So what exactly is Windocks? In short, this is a mixture of a ported version of an existing docker daemon and an open source container project from Uhuru Software. You can read about the features of Windocks and the challenges that developers faced here .

    In the framework of this material, we will try to figure out how working with windocks is fundamentally different from working with the original daemon for linux , what are the current limitations of windocks and whether it is worth introducing the tool into our development and testing processes.

    What is available now


    At the time of writing, windocks supports the following operating systems:
    • Windows 8 / 8.1
    • Windows 10
    • Windows Server 2012 / Windows Server 2012 R2
    • Windows Server 2016


    In these operating systems, you can create containers from images:
    • SQL Server 2016/2014/2012/2008 R2 / 2008
    • Net 4.5 / 3.5 / 2.0
    • Jenkins (agents, demo on request)
    • Office conversion (to convert powerpoint presentations to video, demo on request)
    • Microsoft Dynamics (line of ERP and CRM solutions, demo on request)


    Deploy windocks on VPS with Windows Server 2012


    More recently, Windocks announced the release of community edition, so that you can get acquainted with the product features for free. This version we will deploy. We send the request through the form on the site . The answer comes instantly, and in a minute the link is already with us.

    As the environment for deploying windocks, we will use VPS with a configuration of 2x2.6 GHz, 2 GB RAM, 20 GB HDD / Windows Server 2012 R2. In order to use SQL Server containers on VPS, you must install SQL Server. We install and then install windocks itself. No additional settings are required during the installation process.

    Generate certificates and keys for the host and for the client, to configure two-way authentication and provide them with windocks:
    server-key.pem -> C:\Users\Administrator\.docker\key.pem
    server-cert.pem -> C:\Users\Administrator\.docker\cert.pem
    ca.pem -> C:\Users\Administrator\.docker\ca.pem


    Now run windocks (the start command looks a bit different than for the docker daemon on Linux):
    docker -H tcp://WINDOCKS_IP:2376 -dD --tlsverify=true


    In the startup logs, we see:
    time="2016-06-30T14:32:06.901345300+03:00" level=info msg="Daemon has completed initialization"

    Do not forget to allow incoming connections to tcp port 2376 in the firewall for the desired ip addresses.

    We connect using the standard docker client


    As you probably guessed by the title, Windocks supports docker RESTful api . This means that you can use the standard console client docker to work with it . However, windocks at the moment does not support all commands, but only a part of them. DockerFile also supports a limited set of commands (FROM, ADD, COPY, ADDDB, MOUNTDB). You can find a complete list of commands for comparison here .

    We connect to windocks in the same way as to a regular docker host (for working with the client we recommend creating command aliases, in windows this can be done, for example, using DOSKEY):
    docker.exe --tlsverify --tlscacert=ca.pem --tlscert=cert.pem --tlskey=key.pem -H=WINDOCKS_IP:2376 version


    The result is something like:
    
    Client version: 1.7.0
    Client API version: 1.19
    Go version (client): go1.4.2
    Git commit (client): 0baf609
    OS/Arch (client): windows/amd64
    Server version: $VERSION
    Server API version: 1.19
    Go version (server): go1.5.1
    Git commit (server): $GITCOMMIT
    OS/Arch (server): windows/amd64
    


    Launch .NET application in windocks


    Windocks has its own local registry of images, which in the community addition by default contains 2 images: dotnet and mssql. Its contents can be obtained by executing (we believe that we have already made an alias with parameters for authentication using certificates):
    docker images


    Result:


    So, we have 2 basic images available: dotnet-4.5 and mssql-2014. Together with Windocks there is a set of samples demonstrating its capabilities.

    In this article, we will examine the samples testMountDb and testDotnet. The first mounts the base for the test application in a container created on the basis of the mssql-2014 image. The second - uses this base in work in another container. We copy them to the client OS to carry out the work directly using the standard client.

    Let's collect the container from the testMountDb sample and run it.
    docker build testMountDb


    We get the following:
    
    Sending build context to Docker daemon 2.048 kB
    	Sending build context to Docker daemon
    	Step 0 : FROM mssql-2014
    	Step 1 : MOUNTDB customers C:\dcr\mountDbExample\customerdata.mdf
    	ContainerId = c4d6e4f7bdc9cfc4c8b62b09572b255f43b56716d862b28e291e7af86e08bc3f & ContainerPort = 10001 & ContainerUserName = prison_oo_aqRdapH & ContainerPassword = Pr!5n5A39SvNRo & MSSQLPort = 10001 & MSSQLServerUserName = sa & MSSQLServer
    	SaPassword = Pr!54q0flmqoM1 & DockerFile output:  & Line 2- Mounted DB: customers, C:\ dcr \mountDbExample\customerdata.mdf
    


    From here we will need MSSQLServerUserName and SaPassword, which we will use in web.cfg in the connection string.
    Run the created container:
    docker start c4d


    Now let's collect the container from the testDotnet sample and run it (everything is the same):
    docker build testDotnet


    Result:
    
    SECURITY WARNING: You are building a Docker image from Windows against a Linux Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
    	Sending build context to Docker daemon 20.99 kB
    	Sending build context to Docker daemon
    	Step 0 : FROM dotnet-4.5
    	Step 1 : COPY web.config app-root\\runtime\\repo
    	Step 2 : COPY default.aspx app-root\\runtime\\repo
    	Step 3 : COPY default.aspx.cs app-root\\runtime\\repo
    	Step 4 : COPY main.css app-root\\runtime\\repo
    	Step 5 : COPY windockslogo.png app-root\\runtime\\repo
    	Step 6 : COPY testrun.bat .
    	Step 7 : RUN cmd.exe /C .\testrun.bat
    	ContainerId = 3b8cefeef04d3ac5010fa8e37b04ce42aa207359e4848581222d521839ea7a04 & ContainerPort = 10003 & ContainerUserName = prison_oo_P4yo5gA & ContainerPassword = Pr!5c6g8mVfQq7 & DOTNETPort = 10003 & DockerFile output: PS
    	docker start 3b8
    


    Open in browser
    http://WINDOCKS_IP:10003 
    and, if everything is done correctly, we see the following:


    Now we will save the application image in the windocks registry by doing the following:
    docker commit a29 windocks_dotnet_demo_v1


    And display the updated list of images:
    docker images




    Now other users can use the windocks_dotnet_demo_v1 image

    conclusions


    In our opinion, despite the fact that windocks is quite limited (what its limitations were indicated at the very beginning of the article) in comparison with the Linux docker daemon, it does a good job of its standard tasks of providing SQL Server and .NET containers. It can also be used quite comfortably for developing and testing applications on ASP.NET 4.5 / MSSQL in small teams, but the tool is still too young to be used in production and may become irrelevant after the release of Windows Server 2016. What do you think, dear readers?

    Read Next