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

LangGrant Windocks provides simple database cloning image for enterprise database teams, enabling fast database cloning and virtualization on standard infrastructure.

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

Create and Configure the Dockerfile

First create a file named dockerfile (# indicates comments). If you want to run the scripts below, create those files as well. Put them in the same directory as the dockerfile.

Open the firewall ports for the default SQL Server (usually 1433, but double check). Also open the Windocks auth service / UI ports (3000 and 3001). Additionally, open a range of container ports 10001 to 11000. These are the ports the containers run on.

Configure Network Share Permissions

If the backups or dumps are on a network share, provide full permissions for the Windocks machine name. The permissions should be for reading and writing 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. 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.

dockerfile

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

ENV FULL_BACKUPS_ONLY=1

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

ENV USE_DOCKERFILE_TO_CREATE_CONTAINER=1

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

Build the Image

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. 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

Create a container from the image. This can be done using a command line (only on the Windocks machine), the web application (from any machine), or 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. The script scriptToRunAtContainerCreateTime.sql will be applied to the database.

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

You may also create containers with the REST API.

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

For more information, see the official Microsoft SQL Server documentation.