New-BcContainerWizard aka Business Central on Docker script generator…

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

31 thoughts on “New-BcContainerWizard aka Business Central on Docker script generator…

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

    Like

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

    Like

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

    Like

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

    Like

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

    Like

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

    Like

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

    Like

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

    Like

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

    Like

    • 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?

      Like

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

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s