Build a simple image for fast database cloning and deliver containers with the clones

This article describes building a simple image for a database (from SQL Server full backups, PostgreSQL dumps or MySQL dumps) and delivering fast clones in containers from the image. There are working samples in windocks\samples\cloneFromFullbackup, windocks\samples\mysql, windocks\samples\postgres

First create a file named dockerfile (# indicates comments). If you want to run the scripts below, create those files as well and put them in the same directory as the dockerfile. Open the firewall ports for the default SQL Server (usually 1433, but double check), the Windocks auth service / UI ports (3000 and 3001) and for a range of container ports 10001 to 11000. These are the ports the containers run on. If the backups or dumps are on a network share, provide full permissions for the Windocks machine name to read and write from BOTH the network share AND the directory. For example if your Windocks machine name is PC1, then provide permissions to the account PC1$. In Computer management / Network shares, find the network share on which the backup lives and provide permissions to PC1$. Also in File Explorer, provide full permissions on the highest parent directory to PC1$. The Windocks service runs as LOCALSYSTEM, do not change that. The dockerfile is below:


FROM mssql-2017
# FROM postgres-10.13
# FROM mysql-5.7


SETUPCLONING FULL customers E:\windocks\dbbackups\customerdatafull.bak
#SETUPCLONING FULL customers E:\windocks\dbbackups\postgresdump1
#SETUPCLONING FULL customers E:\windocks\dbbackups\mysqldump1

COPY maskingScript.sql .

# This script is run at image build time
RUN maskingScript.sql

COPY scriptToRunAtContainerCreateTime.sql


# This script is run at container create time
RUN scriptToRunAtContainerCreateTime.sql


Build the image from the above dockerfile. This will create an image and apply the script maskingScript.sql to it

In a command line on the Windocks server:
docker build -t yourimagename path\to\directory\containing\dockerfile

Alternatively, use the web application and click on Build in the top menu and click Browse. Select all the files in the directory (dockerfile, any script files) and then Open. Then click Build.

You may also use the REST API to build the image


Create a container from the image. This can be done using a command line (only on the Windocks machine), or the web application (from any machine) or from the REST API (any machine)

In a command line on the Windocks server:
docker run -d yourimagename

This will deliver a container with a writeable database clone of the customers database and the script scriptToRunAtContainerCreateTime.sql applied to the database

You may also create containers with the clones from the web application at ServerIp:/index.html or the file windocks\ui\index.html in Chrome or Firefox

You may also create containers with the REST API here

View logs of the scripts in the web application by clicking log next to your container / clone.


Extend CI/CD to your data layer