DOCUMENT ARCHIVE

Getting Started with Git and Containers for Development and Test

Windocks supports containers with .Net, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 2014, SQL Server 2016, 2019 on Windows Server 2012 R2, Windows Server 2016, 2019, 2022. Prior to starting, have the following resources available:

  • Windocks Reference
  • Windocks Host IP Address: xx.xx.xx.xx
  • Windocks host RDP login credentials for a VM
  • Install the Docker client on your local machine (see the install guide for docker client download links or use docker.exe in your installation for Windows)
  • Install Git client on the Windocks host. Windows git client is available here

 

 

Working with Windocks on the Host or Remotely

The following exercises can be run remotely if you choose to copy the following items from c:\windocks\samples to your local machine. We recommend that you login to the Windocks Host, and run through these exercises initially on the Host. Note: the Docker command syntax differs when running on the Windocks Host versus a remote connection:

Docker Client Command on the Windocks Host: docker ps

Docker Client on Remote Machine: docker -H=tcp://<Windocks.Host.IP.Address>:2375 ps

To start the Windocks daemon open a new command prompt as administrator and enter:

docker -H tcp://0.0.0.0:2375 -d

RDP to the Windocks Host, open File Explorer, and navigate to \Windocks\samples, and note the folders, databases, and scripts. These will be used in the following exercises, and can be copied to your client machine.

TestGitCloneRepo

The following exercises will be presented as a client running on the Windocks host. The same operations can be performed remotely, but will require the above Test folders be local to the docker client.

 

 

The Setup

We’ll use a public repo on Github.com to pull a .NET application, and show how it is integrated with a SQL Server container. The result is a simple workflow for developers or testers. The tooling is useful for DBA’s, who provide updated SQL Server images and allow the respective teams to self-service integrated environments.

 

 

Step 1: Windocks Host Admin

A Windows container host needs configurable support for “administrative” processes, such as mounting a network hosted database, or working with Git. Windocks includes support for configuring administrative processes via the \Windocks\config\node.cfg file. Git is supported in our illustration below by enabling any CMD command on the host. You will see “RUN_AS_ADMIN_CMD” used later to support Git commands.

Gitclone Blog Image 1 650 x 200

 

 

Step 2: Git clone https://github.com/Windocks

Two public github repos are used. GitDockerFile is the DockerFile that will clone our .NET application (DotNetSample). The GitDockerFile also includes a PowerShell script that we’ll use later. Open a command prompt as Admin, and clone the GitDockerFile to your local machine:

Gitclone Blog Image 2 650 x 175

 

Use File Explorer to open the DockerFile. The DockerFile defines a sequence of commands that are executed sequentially by the Docker daemon. DockerFiles begin with the base image, and this one refers to the .NET-4.5 image. The second step “Git Clones” the dotnetsample repo to the container. The third step copies the web.config file into the container.

Gitclone Blog Image 3 650 x 100

 

Open a Web browser, and navigate to the host address and port to view the integrated application.

 

 

Step 3: Build an Integrated Environment

Refer to both images below for the sequence in creating an integrated .NET + SQL Server container environment. There are three steps: 1) create and start the SQL Server container, 2) edit the web.config file to include the SQL port and password, 3) launch the .NET application.

Once the SQL Server container is running, open the TestGitClone folder (that was cloned from the Git repo), and open the web.config file using notepad. Edit the IP address and port, and the sa password as shown. When updated, build the .Net container. 

Gitclone Blog Image 5 650 x 200

 

The sequence of building the two containers is shown below. The Docker Build incorporates the Git clone in the building of the .NET application. The final step is to start the .NET application.

Gitclone Blog Image 4 650 x 250

 

Congratulations, you’ve built a fully integrated container environment. Open a browser and navigate to the localhost:10004\dotnetsample to see the integrated environment. The SQL Server container is accessible through SQL Server Management studio, or other tools. The Windocks base .NET image includes a similar instance of the .NET application, so in this case we actually have two applications running in the container. This isn’t a recommended practice, but doesn’t affect the purpose of this exercise. The base image application is accessible at: localhost:10004

Gitclone Blog Image 6 650 x 320

 

 

Next steps

Windows containers with Docker commands are simple to use, and is a powerful new option for developers and testers for self-service integrated environments. DBA’s can easily provide approved SQL Server images for team use. Explore the future of Windows based development by downloading your own Windocks Community Edition. 

Extend CI/CD to your data layer