Windocks supports the running of EXEs, Powershell scripts, Windows commands, Bash from the dockerfile. This is available in Enterprise edition. These commands can be run at image build time, container create time, or after container start. See the sample in windocks\samples\powershellOnDatabase
Specifying commands to run in the dockerfile
The dockerfile specifies WHEN to run the Powershell or EXEs. There are 4 choices on when to run the Powershell or EXEs.
- Image build time
- Image build time after the image databases are ready
- When a container is created from this image
- When a container is created from this image time after the container databases are ready
First create the dockerfile as follows (# is used for commenting lines):
dockerfile
FROM mssql-2016
SETUPCLONING FULL customers C:\windocks\dbbackups\customerdatafull.bak
# COPY powershellScriptAtCreate.ps1 .
# COPY custom.exe .
COPY mask.ps1 .
COPY deploy.ps1 .
# This Powershell runs at image build time but NOT on the image databases RUN somePowershell.ps1 # This Powershell runs on the database in the image at image build time
# Because the powershell is run on the image databases, all containers created from this image will have the effects of this script
# $ContainerDir and $ContainerPort are populated by Windocks automatically with the values of the container used to build the image.
RUN RUN_ON_IMAGE_DATABASES powershell.exe $ContainerDir\mask.ps1 -dest LAPTOP-DA9D6LTM\INSTANCE$ContainerPort
# Anything below this line runs after a container create is created from the image
ENV USE_DOCKERFILE_TO_CREATE_CONTAINER=1
# This Powershell runs at container create time. This container is the one being created by the user and NOT the container used to build the image
# $ContainerDir is populated by Windocks automatically with the actual values for the container created by the user
RUN powershell.exe $ContainerDir\powershellScriptAtCreate.ps1
# You may also run EXEs like Powershell # RUN .\custom.exe $ContainerPort
# This Powershell runs on container create after the container databases are ready
# $ContainerDir and $ContainerPort are populated by Windocks automatically. The instance name for the SQL container is INSTANCE$ContainerPort
RUN RUN_ON_CONTAINER_START powershell.exe $ContainerDir\deploy.ps1 -dest LAPTOP-DA9D6LTM\INSTANCE$ContainerPort