How-to: Run LS Central in a Docker container

Microsoft have been releasing Business Central (formerly Dynamics NAV) as Docker images for a few years now. These have been great for testing and learning the new developer tools and trying out new functionality, but in real life many of us don’t use vanilla Business Central. You, like me, probably need an ISV solution and it’s demo data before Docker is useful on customer projects and demos.

This blog post shows one way you can get LS Central by LS Retail running in a Docker container.

LS Central releases contain a demo .bak file which we’ll use to replace the default .bak file that comes with Business Central. We’ll also need the client and server add-in files to deploy to the container.

Note it’s important that any installer packages can run in unattended/silent mode as Windows Server Core based containers do not have a GUI to handle any user interaction. One way to check this is to run the .exe with the /? parameter and see if it prints out any information. LS Central installers use the /silent parameter:

PS C:\Temp\LS> & '.\LS Central 13.04.00.852 Client Components.exe' /?

---------------------------
Setup
---------------------------
The Setup program accepts optional command line parameters.


/HELP, /?

Shows this information.

/SP-

Disables the This will install... Do you wish to continue? prompt at the beginning of Setup.

/SILENT, /VERYSILENT

Instructs Setup to be silent or very silent.

/SUPPRESSMSGBOXES

Instructs Setup to suppress message boxes.

/LOG

Causes Setup to create a log file in the user's TEMP directory.

/LOG="filename"

Same as /LOG, except it allows you to specify a fixed path/filename to use for the log file.

/NOCANCEL

Prevents the user from cancelling during the installation process.

/NORESTART

Prevents Setup from restarting the system following a successful installation, or after a Preparing to Install failure that requests a restart.

/RESTARTEXITCODE=exit code

Specifies a custom exit code that Setup is to return when the system needs to be restarted.

/CLOSEAPPLICATIONS

Instructs Setup to close applications using files that need to be updated.

/NOCLOSEAPPLICATIONS

Prevents Setup from closing applications using files that need to be updated.

/RESTARTAPPLICATIONS

Instructs Setup to restart applications.

/NORESTARTAPPLICATIONS

Prevents Setup from restarting applications.

/LOADINF="filename"

Instructs Setup to load the settings from the specified file after having checked the command line.

/SAVEINF="filename"

Instructs Setup to save installation settings to the specified file.

/LANG=language

Specifies the internal name of the language to use.

/DIR="x:\dirname"

Overrides the default directory name.

/GROUP="folder name"

Overrides the default folder name.

/NOICONS

Instructs Setup to initially check the Don't create a Start Menu folder check box.

/TYPE=type name

Overrides the default setup type.

/COMPONENTS="comma separated list of component names"

Overrides the default component settings.

/TASKS="comma separated list of task names"

Specifies a list of tasks that should be initially selected.

/MERGETASKS="comma separated list of task names"

Like the /TASKS parameter, except the specified tasks will be merged with the set of tasks that would have otherwise been selected by default.

/PASSWORD=password

Specifies the password to use.


For more detailed information, please visit http://www.jrsoftware.org/ishelp/index.php?topic=setupcmdline
---------------------------
OK   
---------------------------

Of course if the installer is only adding DLLs to the add-ins folder then you could also get these files from another machine and copy them into the container. Have a look at the docker cp command documentation to see how to copy files into a container.

We’re going to use the Create-NavContainer Cmdlet from the NavContainerHelper PowerShell module to build the container and use the LS demo database. We can use the -myScripts parameter to copy the LS components into the container, and then install them individually using the shell desktop shortcut the NavContainerHelper module creates.

I used a script from Freddy’s Blog and adapted to suit. The steps look like this, adjust as required:

$imageName = "mcr.microsoft.com/businesscentral/onprem:cu3"
$navcredential = New-Object System.Management.Automation.PSCredential -argumentList "admin", (ConvertTo-SecureString -String "admin" -AsPlainText -Force)
New-NavContainer -accept_eula `
-containerName "LSDEMO" `
-Auth NavUserPassword `
-imageName $imageName `
-Credential $navcredential `
-licenseFile "https://www.dropbox.com/<blanked out>/Licence.flf?dl=1" `
-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") `
-additionalParameters @('--env bakfile="c:\run\my\w1-ls-central-13-04-release.bak"') `
-useBestContainerOS `
-includeCSide `
-updateHosts `
-enableSymbolLoading

In the above PowerShell script which I ran from PowerShell ISE, I copy the demo database and LS component installers into the containers C:\run\my directory using the -myScripts parameter, and then replace the database used during installation using the -additionalParameters parameter.

Note: you must match the correct Business Central image for your demo database. LS Central 13.04 is based on Business Central On-prem CU3, check the release notes for the version you need and adjust he image name in the script above.

So far so good, we have a running container but if we try and use the system we’ll quickly bump into a missing component error. Next we’ll need to install the LS components.

The NavContainerHelper Module has conveniently left a command line shortcut on my desktop:

We can use this to install our LS components which we loaded into the container c:\Run\my directory earlier:

We now have LS Central running in our Docker container.

If you want to use the LS Windows Client POS you’ll also need to copy the LS client components into local RTC add-ins folder created by NavContainerHelper. Assuming the container name is LSDEMO, the local add-in folder can be found on the Docker host machine here:

C:\ProgramData\NavContainerHelper\Extensions\LSDEMO\Program Files\130\RoleTailored Client\Add-ins

Enjoy!

See Part 2 to automate creation further:

How-to: Run LS Central in a Docker container – Part 2

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.