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

27 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

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