Docker Nav Container stopped working - Cannot index into a null array.

CyberghostCyberghost Member Posts: 46
Hi all,

When I run the following command, I end up with a Cannot index into a null array error. What's weird is that this used to work fine.

Any ideas how to resolve will be gratefully received. Command and output shown below.

Also, if anyone has an example of how to run either a Docker command or a New-NAVContainer command which connects to a SQL database on the laptop (rather than in a docker container) they could share it would be appreciated. I've tried numerous variations but don't seem to be able to get it right.



docker run -e accept_eula=Y -e clickonce=Y -e useSSL=N -e username=admin -e password=XXXXXXXXX -m 4G -P -h NAV2017RTM --name NAV2017RTM -v c:\DockerShare:c:\run\my microsoft/dynamics-nav:2017-rtm-gb

Initializing...
Starting Container
Hostname is NAV2017RTM
PublicDnsName is NAV2017RTM
Using NavUserPassword Authentication
Starting Local SQL Server
Starting Internet Information Server
Creating Self Signed Certificate
Self Signed Certificate Thumbprint 64A84AE11C9D549A6C6AE3AAFC6984E347C4C798
Modifying NAV Service Tier Config File with Instance Specific Settings
Starting NAV Service Tier
Creating Web Site
Creating NAV Web Server Instance
Creating http download site
Creating Windows user admin
Enabling SA
Creating NAV user
Creating ClickOnce Manifest
Cannot index into a null array.

Cheers

Chris
"When you eliminate the impossible, whatever remains, however improbable, must be the truth" - Sherlock Holmes

"God and developers are in a constant battle. Developments to make their applications more idiot-proof, and God to produce bigger idiots!"

Answers

  • yukonyukon Member Posts: 361
    edited 2018-01-15
    Hi,

    Do you remove the default nat network from docker network? If yes, you need to add back the default nat and try to run the cmd again. If you still have issue you can post at here "https://github.com/Microsoft/nav-docker/issues". You can use below command to check docker network.

    docker network ls

    For second question New-NAVContainer.

    Powershell.

    ### Author Yukon
    ### Disable the network to work properly. I don't care security because i'm using my own network
    Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False

    $imageName = "microsoft/dynamics-nav:2018-au" ### change the image name base on requirement
    ### Auto increase and create the container
    $containerName = ("nav" + $imageName.Split(':')[1]).ToLower()

    if ((docker ps --no-trunc -qf "name=$containerName").count -ne 0){
    $containerName += (docker ps --no-trunc -qf "name=$containerName").count
    ### here is bug but lazy to fix. but still can use :)
    }
    ### End Auto increase and create the container

    $DatabaseServer = $env:COMPUTERNAME ### Change the value if your SQL is host on other server. Default is current computer.
    $DatabaseInstance = "" #### Fill up if you have different instance
    $DatabaseName = "" ### Required
    $DatabaseUserName = "" ### Required
    $DatabasePassword = "" ### Required
    $TrustSQLServerCertificate = $true

    $DatabaseSecurePassword = ConvertTo-SecureString -String $DatabasePassword -AsPlainText -Force
    $DatabaseCredentials = New-Object PSCredential -ArgumentList $DatabaseUserName, $DatabaseSecurePassword

    $Serverinstance = "nav" ### Don't change it hard code inside navision container
    $UserName = "" ### Required. Just Name only, no need computer name.
    $UserPassword = "" ### Required and complex password is required
    $UserCredential = New-Object PSCredential -ArgumentList $UserName, (ConvertTo-SecureString -String $UserPassword -AsPlainText -Force)
    $IsWindowsAuth = $false ### Base on your requirement

    $licenseFile = "" ### Demo not required but if you want to do some change on navision it'll require

    $memoryLimit = 2G ### I used 2Gb because sometime fail to run. Default is 3Gb.
    ### Start Spin Navision Container
    if ($IsWindowsAuth ){
    New-NavContainer -accept_eula `
    -containerName $containerName `
    -imageName $imageName `
    -memoryLimit $memoryLimit `
    -includeCSide -auth Windows `
    -Credential $UserCredential `
    -enableSymbolLoading `
    -doNotExportObjectsToText `
    -databaseServer $DatabaseServer `
    -databaseName $DatabaseName `
    -databaseCredential $DatabaseCredentials `
    -licenseFile $licenseFile `
    -additionalParameters @("-e ExitOnError=Y")
    }else{
    New-NavContainer -accept_eula `
    -containerName $containerName `
    -imageName $imageName `
    -memoryLimit $memoryLimit `
    -includeCSide -auth NavUserPassword `
    -enableSymbolLoading `
    -doNotExportObjectsToText `
    -databaseServer $DatabaseServer `
    -databaseName $DatabaseName `
    -databaseCredential $DatabaseCredentials `
    -licenseFile $licenseFile `
    -additionalParameters @("-e ExitOnError=Y")
    }
    ### End Spin Navision Container


    ### Bonus auto create the navision user.
    ### Default is not create the user if we are using external database.
    $ContainerId = (docker ps --no-trunc -qf "name=$containerName")
    $PSSession = New-PSSession -ContainerId $ContainerId -RunAsAdministrator

    $ScriptBlockNewUser = { param($Serverinstance,$UserName,$UserCredential,$IsWindowsAuth)
    Import-Module "C:\Program Files\Microsoft Dynamics NAV\110\Service\Microsoft.Dynamics.Nav.Management.dll" -Force;

    if ($IsWindowsAuth){
    $UserName = ("$env:COMPUTERNAME\$UserName").ToUpper();
    $Result = Get-NAVServerUser -ServerInstance $Serverinstance | Where-Object {$_.WindowsAccount -eq $UserName}

    if ($Result -eq $null){
    New-NAVServerUser -ServerInstance $Serverinstance -WindowsAccount $UserName;
    New-NAVServerUserPermissionSet -ServerInstance $Serverinstance -WindowsAccount $UserName -PermissionSetId "SUPER";
    Write-Host "User is created" -ForegroundColor Yellow
    }
    }else{
    $Result = Get-NAVServerUser -ServerInstance "nav" | Where-Object {$_.username -eq $UserName}

    if ($Result -eq $null){
    New-NAVServerUser -ServerInstance $Serverinstance -UserName $UserName -Password $UserCredential;
    New-NAVServerUserPermissionSet -ServerInstance $Serverinstance -UserName $UserName -PermissionSetId "SUPER";
    Write-Host "User is created" -ForegroundColor Yellow
    }
    }
    }

    Invoke-Command -Session $PSSession -ScriptBlock $ScriptBlockNewUser -ArgumentList $Serverinstance,$UserName,$UserCredential,$IsWindowsAuth

    copy above script and past ps file and save it to start.ps1. And you can run it from powershell administrator console. Can't run from Powershell ISE.

    Regards,
    Yukon.
    Make Simple & Easy
Sign In or Register to comment.