In my previous blog post How-to: Run LS Central in a Docker container I showed how you can run LS Central on Docker with some manual steps to get the client and server components installed.
For this blog post I’m going to show a more reusable solution where you can install the client components via a script passed into the container.
To make the Business Central Docker images configurable, the designers decided to incorporate a set of Powershell script files which can be substituted at build time to override the standard setup process. The standard scripts are found in the containers C:\Run directory:
The AdditionalSetup.ps1 script file, which is empty by default, when overwritten will execute after the main setup has completed. This is where we can provide code to install additional components such as client and service add-ins.
When you place a script with the same name into the containers C:\Run\my directory, Docker will use this version of the file instead of the standard version. As we saw in my previous blog post the New-NavContainer Cmdlet’s -myScripts parameter is used to copy files from the Docker host into the containers C:\Run\my directory.
I’ve created an AdditionalSetup.ps1 file with the following content:
Write-Host "Installing LS Client Components.." & "C:\Run\my\LS Central 13.04.00.852 Client Components.exe" /silent Write-Host "Installing LS Service Components.." & "C:\Run\my\LS Central 13.04.00.852 Service Components.exe" /silent Write-Host "Remove database backup.." Remove-Item -Path 'C:\Run\my\*' -Include *.bak
Note: The reason I’m not cleaning up the installer files is because I was getting an access denied error. If anyone knows why I can delete the database backup but not the .exe files please let me know in the comments!
For this example I’ve created a folder on the Docker host machine with the following content:
Now I can run a script to build the container, using my setup files and additional setup script:
$imageName = "mcr.microsoft.com/businesscentral/onprem:1810-cu3" $navcredential = New-Object System.Management.Automation.PSCredential -argumentList "admin", (ConvertTo-SecureString -String "admin" -AsPlainText -Force) New-NavContainer -accept_eula ` -containerName "LSDEMO2" ` -Auth NavUserPassword ` -imageName $imageName ` -Credential $navcredential ` -licenseFile "C:\Temp\LS\BC13License.flf" ` -updateHosts ` -alwaysPull ` -additionalParameters @('--env bakfile="c:\run\my\w1-ls-central-13-04-release.bak"') ` -myScripts @(` "C:\Temp\LS\w1-ls-central-13-04-release.bak", ` "C:\Temp\LS\LS Central 13.04.00.852 Client Components.exe", ` "C:\Temp\LS\LS Central 13.04.00.852 Service Components.exe", ` "C:\Temp\LS\AdditionalSetup.ps1"` ) ` -memoryLimit 8GB ` -accept_outdated ` -doNotExportObjectsToText
The post How-to: Run LS Central in a Docker container – Part 2 appeared first on Dan Kinsella.
*This post is locked for comments