Modifying scripts inside standard images

As you have seen, Dynamics 365 Business Central container images have a lot of configuration options, giving you the possibility to change a lot of their behavior. However, if you ever run into a situation where you need to run a different container configuration setup, images have one more ace up their sleeve: you can override any script in the container.

The mechanism for this works by placing a script with the exact same name as the one you want to override into the c: unmy folder in your container. The easiest way to do that is through a volume. Assuming that you have a folder such as c:c-override with anAdditionalSetup.ps1 file, you can do the following:

docker run -e accept_eula=y -v c:c-override:c:
unmy mcr.microsoft.com/businesscentral/onprem

When the container gets to the place where AdditionalSetup.ps1 is called, it checks whether a file with that name exists in c: unmy and if so, calls it. If not, it calls the standard script with that name, which is stored in c: un. This script may look as follows:

Write-Host "----- Hello from the override script --------------------"

If it does, you will get the following output when starting the container:

Initializing...
Starting Container
Hostname is 4e58d9587fb0
PublicDnsName is 4e58d9587fb0
Using NavUserPassword Authentication
Starting Local SQL Server
Starting Internet Information Server
Creating Self Signed Certificate
Self Signed Certificate Thumbprint 1462D57EE355D19018232160C396159313A20893
Modifying Service Tier Config File with Instance Specific Settings
Starting Service Tier
Creating DotNetCore Web Server Instance
Enabling Financials User Experience
Creating http download site
Creating Windows user admin
Setting SA Password and enabling SA
Creating admin as SQL User and add to sysadmin
Creating SUPER user
----- Hello from the override script --------------------
Container IP Address: 172.26.148.48
Container Hostname : 4e58d9587fb0
Container Dns Name : 4e58d9587fb0
Web Client : https://4e58d9587fb0/BC/
Admin Username : admin
Admin Password : Rohy1060
Dev. Server : https://4e58d9587fb0
Dev. ServerInstance : BC
Files:
http://4e58d9587fb0:8080/al-4.0.192371.vsix
http://4e58d9587fb0:8080/certificate.cer
Initialization took 117 seconds
Ready for connections!

Using the navcontainerhelper utility, you would call it like this:

New-NavContainer -accept_eula -imageName mcr.microsoft.com/businesscentral/sandbox -myScripts @("c:c-overrideAdditionalSetup.ps1") mycontainer

Alternatively, sincenavcontainerhelper has a more convenient way of doing things, you can just add your PowerShell script code inline:

New-NavContainer -accept_eula -imageName mcr.microsoft.com/businesscentral/sandbox -myscripts @( @{ "AdditionalSetup.ps1" = "Write-Host ‘----- Hello from the override script --------------------'" } ) mycontainer

With this very powerful feature, you can change every script in the container to suit your needs. To get an idea of what you can adjust, please check out https://github.com/Microsoft/nav-docker/tree/master/generic/Run.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.121.131