Update 2021/2/10: BcContainerHelper has replaced NavContainerHelper. This blog post still reference NavContainerHelper, which is outdated.
I have been wanting to create a repository of scripts, where you could locate the right script for your usage. The problem I ran into was however that the number of scripts in a repository like that would very quickly explode. Yesterday evening while riding my bike, I got an idea…
Why not create a script generator script for Business Central on Docker. A script, which asks you a lot of questions and then generates a script, which you can save and run.
New-BcContainerWizard
The script will be evolved over time, but it can already do cool stuff and feedback is very welcome…
Before running any scripts, you will need the latest NavContainerHelper module installed (https://www.powershellgallery.com/packages/navcontainerhelper)
With the latest ContainerHelper you can run
New-BcContainerWizard
Then you will run the version of the script, which is included in your version of NavContainerHelper.
There might however be a newer version of the script online. The way you can run this is, that you start Windows PowerShell (ISE and VSCode also works) and run this script:
Invoke-Expression (New-Object System.Net.WebClient).DownloadString("http://aka.ms/bcdockerscript")
You are of course welcome to download and inspect the script if you like, but the script will be updated in its location regularly. When launching the script you should see:

Type Y and continue. Now you will be lead through a number of questions and for each question, I will try to explain what this means. First question is if you want to run locally or inside an Azure VM.

You will also need to specify which Business Central version you want and which country version you want and in the end, the script will display the script needed to create the container you want, giving you a chance to save it and execute it:

Executing the script should give you a container, with the things you specified in the script:

If you instead select an Azure VM, then you “script” will be a URL, which launches one of the ARM templates with a number of parameters pre-filled with your selectioins.

Try it out!
Try it out and let me know if there are bugs and what you think is missing?
Enjoy
Freddy Kristiansen
Technical Evangelist
Hi, ran it and it gave the following error:
Invoke-Expression : The term ‘Get-BcArtifactUrl’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Invoke-Expression (New-Object System.Net.WebClient).DownloadString(“h …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-BcArtifactUrl:String) [Invoke-Expression], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.InvokeExpressionCommand
LikeLike
The script has a dependency on the latest NavContainerHelper – I will add a check to the script.
LikeLike
I have added that to the text now.
LikeLike
Tested it out in a simple scenario.
Local docker, specific build and localization -> worked just fine.
Something like this with a GUI would be perfect for introducing docker to non-technical consultants.
I’ve been wanting to try out portainer, but haven’t had the chance.
This is a step in that direction!
LikeLike
Minor comment..
I reference the license filed enclosed with ” ” – this broke the script, with “cannot find path” or similar error.
LikeLike
Good point, will Trim quotes from the path.
LikeLike
Thanks, yes will evolve this along the way and let’s see what happens.
LikeLike
Maybe you should consider adding a question of shortcut location?
LikeLike
Hello,
For the script work in my installation I need to download it and change this line
$module = Get-Module -Name “NavContainerHelper” -ErrorAction SilentlyContinue
to this one:
$module = Get-InstalledModule -Name “NavContainerHelper” -ErrorAction SilentlyContinue
LikeLike
Thanks for the information.
LikeLike
Great idea. Worked for me like a charm 🙂
LikeLiked by 1 person
when executing the generated script, it gives an error for my version of Win10, it indicates that it is not compatible. You can help? what change in the script?
LikeLike
Could you create an issue on http://www.github.com/microsoft/navcontainerhelper and include the generated script and the full output – then I will fix the generator if possible (and help you fix the script)
LikeLike
Hi Freddy, this might be my favorite update to date 🙂 Great work!!
LikeLike
Really nice. I like that! Especially the dns setting.
LikeLike
Would be nice if we could import the license from a network path like
$licenseFile = ‘\\server02\Lizenzen’
LikeLike
sorry I missed the actual file: \\server02\Lizenzen\fin.flf
LikeLiked by 1 person
Have you tried? – Somebody wrote to me that it works.
LikeLike
Small typo in the dns section “Add Google publis dns…” should be “Add Google public dns…”
DNS
On some networks, default DNS resolution does not work inside a running container.
When this is the case, you will see a warning during start saying:
WARNING: DNS resolution not working from within the container.
Some times, this can be fixed by choosing a different DNS server. Some times you have to reconfigure your network or antivirus settings to allow this.
a Use default DNS settings (configured in Docker Daemon)
b Add Google publis dns (8.8.8.8) as DNS to the container
c Add your hosts primary DNS server (192.168.1.254) as DNS to the container
LikeLike
Thanks – will fix
LikeLike
It didn’t work for me this morning. The create container script was generated, but when I tried to run it, I got this error: PS C:\Windows\system32> C:\Windows\system32\createcontaineras.ps1
% : Cannot convert value “20200211” to type “System.Version”. Error: “Version string portion was too short or too long.”
At C:\Program Files\WindowsPowerShell\Modules\navcontainerhelper\0.7.0.12\ContainerHandling\Get-BestGenericImageName.ps1:28 char:72
+ … ke $tag } | % { [System.Version]($_.SubString($tag.indexOf(‘*’), $_.l …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [ForEach-Object], RuntimeException
+ FullyQualifiedErrorId : InvalidCastParseTargetInvocation,Microsoft.PowerShell.Commands.ForEachObjectCommand
Not sure if it’s related to navcontainerhelper version.
LikeLike
Sounds like a bug
LikeLike
0.7.0.12 is bad – sorry – grab the update,, that one should fix this issue.
LikeLike
Thankyou!
LikeLike
Hi, I have the following error when saving the script:
Save and Edit script
$containerName = ‘my’
$password = ‘P@ssword’
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force
$credential = New-Object pscredential ‘admin’, $securePassword
$auth = ‘UserPassword’
$artifactUrl = Get-BcArtifactUrl -type ‘Sandbox’ -version ” -country ‘us’ -select ‘Latest’
New-BcContainer `
-accept_eula `
-containerName $containerName `
-credential $credential `
-auth $auth `
-artifactUrl $artifactUrl `
-imageName ‘testimg’ `
-updateHosts
Filename (or blank to skip saving) (default blank) test.ps1
start : Este comando no se puede ejecutar debido al error: No hay ninguna aplicación asociada con el archivo
especificado para esta operación.
En C:\Program Files\WindowsPowerShell\Modules\navcontainerhelper\0.7.0.13\CreateScript.ps1: 810 Carácter: 9
+ start -Verb Edit $filename
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
PS C:\temp>
LikeLike
Please create issues on http://www.github.com/microsoft/navcontainerhelper/issues – not on the blog post.
For this error though – you need to enter a full path and filename – not just test.ps1. I will try to make a better explanation.
LikeLike
Excellent wizard, I see that there’s no GB localisation… Is this due to the artifacts not being available for the latest version?
LikeLike
When I run Get-Command -Module navcontainerhelper I don’t see New-BcContainerWizard. However, I tried Invoke-Expression (New-Object System.Net.WebClient).DownloadString(“http://aka.ms/bcdockerscript”) and works great with locally hosted and Azure hosted containers. Thank you!
LikeLike
You probably just need a later version of containerhelper.
LikeLike
It seems there is no access to the script today :
Exception calling “DownloadString” with “1” argument(s): “The remote server returned an error: (404) Not Found.”
http://aka.ms/bcdockerscript =>
https://raw.githubusercontent.com/microsoft/navcontainerhelper/dev/CreateScript.ps1
404 not found
LikeLike
Sorry, I have fixed that
LikeLiked by 1 person
I’ve never had the time to thank you for your great work on the container helpers. I think it was simple enough to create your own scripts if you read your posts. However, other consultants I know have struggled. This is brilliant, it’s the no more excuses tool I’ve been searching for.
Thanks.
LikeLike
Thank you Freddy for all your work. The wizard works perfectly if I might suggest some additional features I would like to see some parameters allowing to provide answers to some of the questions before executing the wizard allowing for some of the question to be “pre-answered” once the wizard runs (e.g.: “Container Name”, “License File”, “External Database Connection String”).
Thank again for all your work
LikeLike
It sounds like you are suggesting to parameterize the Wizard.
The Wizard is intended as a Script generator. If you save the script, then you have the script needed and variables for those things in the beginning.
or do I misunderstand something?
LikeLike
Dear Freddy,
First of all, lets me thanks for your great effort. When I am trying this method, I am facing errors when creating the docker.
Using the below script:
=====================
$containerName = ‘sthbc17w1’
$password = ‘P@ssw0rd’
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force
$credential = New-Object pscredential ‘admin’, $securePassword
$auth = ‘UserPassword’
$artifactUrl = Get-BcArtifactUrl -type ‘OnPrem’ -country ‘w1’ -select ‘Latest’
$licenseFile = ‘F:\BCLicense\license.flf’
New-BcContainer `
-accept_eula `
-containerName $containerName `
-credential $credential `
-auth $auth `
-artifactUrl $artifactUrl `
-imageName ‘sthbc17w1’ `
-licenseFile $licenseFile `
-includeAL `
-updateHosts
Here is the error:
======================
PS >C:\Users\X220\Documents\bc17w1scripts.ps1
BcContainerHelper is version 1.0.8
BcContainerHelper is running as administrator
Host is Microsoft Windows 10 Pro – 2004
Docker Client Version is 19.03.13
Docker Server Version is 19.03.13
Fetching all docker images
ArtifactUrl and ImageName specified
Building image sthbc17w1:onprem-17.0.16993.0-w1 based on mcr.microsoft.com/dynamicsnav:10.0.19041.508-generic with https://bcartifacts.azureedge.net/onprem/17.0.16993.0/w1
Pulling latest image mcr.microsoft.com/dynamicsnav:10.0.19041.508-generic
10.0.19041.508-generic: Pulling from dynamicsnav
Digest: sha256:68ff2cc147a48b35c0635250d0632e80bc81503a338b1b8e77a92649618ca928
Status: Image is up to date for mcr.microsoft.com/dynamicsnav:10.0.19041.508-generic
mcr.microsoft.com/dynamicsnav:10.0.19041.508-generic
Generic Tag: 0.1.0.24
Container OS Version: 10.0.19041.508 (2004)
Host OS Version: 10.0.19041.508 (2004)
Using process isolation
Using license file F:\BCLicense\license.flf
Files in c:\bcartifacts.cache\tmp637383035308384873\my:
Copying Platform Artifacts
Copying Database
Copying Licensefile
c:\bcartifacts.cache\tmp637383035308384873
Sending build context to Docker daemon 1.304GB
Step 1/6 : FROM mcr.microsoft.com/dynamicsnav:10.0.19041.508-generic
—> a1beef6c2e2c
Step 2/6 : ENV DatabaseServer=localhost DatabaseInstance=SQLEXPRESS DatabaseName=CRONUS IsBcSandbox=N artifactUrl=https://bcartifacts.azureedge.net/onprem/17.0.16993.0/w1
—> Running in 5a4e65281163
docker : hcsshim::PrepareLayer – failed failed in Win32: Incorrect function. (0x1)
At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\1.0.8\ContainerHandling\New-NavImage.ps1:521 char:1
+ docker build –isolation=$isolation –memory $memory –tag $imageName …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (hcsshim::Prepar…function. (0x1):String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
I will be greatly appreciated if you can suggest to me.
Best Regards,
Si Thu
LikeLike