Starting with Container-Based Development using Dockers

by Jun 30, 2020Runtime

Home 9 Development 9 Runtime 9 Starting with Container-Based Development using Dockers

Microsoft Dynamics 365 Business Central offers images for container-based development. Creating a new development environment using this container-based image (with Docker) is especially quick and easy.

Install Docker

The first thing that must be done is installing Docker. Docker. The current stable version for Windows could be found directly on docker.com (Windows 10).

Once the Docker is installed (the installation will probably require a restart of the computer), set the docker to use Windows containers (in Taskbar, right-click on the Docker icon and choose “Switch to Windows Containers”. If you already have any Linux containers, they won’t be deleted, but you won’t be able to manage them while you are working with Windows containers.

Create Container

The easiest way how to install container is to use PowerShell module created by Freddy Kristiansen that is available on powershellgallery.com.

This module contains many functions that are prepared directly for using for the Business Central and helps a lot with any task from creating to managing containers.

To start with, open a PowerShell (run as an administrator) and install this module using Install-Module command. Then import the module using Import-Module.

Install-Module -Name navcontainerhelper
Import-Module navcontainerhelper

Once we have the module installed & imported, we can create a new container using New-NavContainer function (see details of how to use this function in Freddy’s article where he introduced all new functions in the NavContainerHelper module).

PS C:\WINDOWS\system32> Measure-Command {
    $artifactUrl = Get-BCArtifactUrl -version 16.4 -select Latest -country w1
    $credential = New-Object pscredential 'Kepty', (ConvertTo-SecureString -String 'TKA@Password' -AsPlainText -Force)
    New-NavContainer `
        -accept_eula `
        -containerName Kepty-Demo `
        -artifactUrl $artifactUrl `
        -Credential $credential `
        -auth UserPassword `
        -updateHosts `
        -imagename 16-4-w1
}

Using this script, we create a new container with the name “Kepty-Demo”, credentials “Kepty” / “TKA@Password” with an image of Business Central 16.4 W1.

Once the script finishes (it may take time, sometimes up to 45 minutes till the image is downloaded and container created).

NavContainerHelper is version 0.7.0.26
NavContainerHelper is running as administrator
Host is Microsoft Windows 10 Education - 1909
Docker Client Version is 19.03.13
Docker Server Version is 19.03.13
ArtifactUrl and ImageName specified
Fetching all docker images
Downloading application artifact /sandbox/16.4.14693.19714/w1
Downloading C:\Users\Kepty\AppData\Local\Temp\acc7c156-c5c5-46ac-b407-d987704aa4bb.zip
Unpacking application artifact to tmp folder using Expand-Archive
Image 16-4-W1:sandbox-16.4.14693.19714-w1 doesn't exist
Building image 16-4-W1:sandbox-16.4.14693.19714-w1 based on https://bcartifacts.azureedge.net/sandbox/16.4.14693.19714/w1
Pulling latest image mcr.microsoft.com/dynamicsnav:10.0.18363.1198-generic
10.0.18363.1198-generic: Pulling from dynamicsnav

9038b92872bc: Pulling fs layer
...
d2c27142114e: Pulling fs layer
4e34d77e7c33: Waiting
...
d2c27142114e: Waiting
ebf009e1d015: Verifying Checksum
ebf009e1d015: Download complete
...
708d38bb8af6: Verifying Checksum
708d38bb8af6: Download complete
9038b92872bc: Pull complete
...
d2c27142114e: Pull complete
Digest: sha256:6c7974113fc53b0eda6db752409b9bebfd1c7dce8327bcf6fe0f917a5104d50f
Status: Downloaded newer image for mcr.microsoft.com/dynamicsnav:10.0.18363.1198-generic
mcr.microsoft.com/dynamicsnav:10.0.18363.1198-generic
Generic Tag: 0.1.0.24
Container OS Version: 10.0.18363.1198 (1909)
Host OS Version: 10.0.18363.1198 (1909)
Downloading platform artifact /sandbox/16.4.14693.19714/platform
Downloading C:\Users\Kepty\AppData\Local\Temp\c57ebf7f-be77-488b-a31c-5647f9933ee8.zip
Unpacking platform artifact to tmp folder using Expand-Archive
Downloading Prerequisite Components
Downloading c:\bcartifacts.cache\sandbox\16.4.14693.19714\platform\Prerequisite Components\Open XML SDK 2.5 for Microsoft Office\OpenXMLSDKv25.msi
Downloading c:\bcartifacts.cache\sandbox\16.4.14693.19714\platform\Prerequisite Components\IIS URL Rewrite Module\rewrite_2.0_rtw_x64.msi
Downloading c:\bcartifacts.cache\sandbox\16.4.14693.19714\platform\Prerequisite Components\DotNetCore\DotNetCore.1.0.4_1.1.1-WindowsHosting.exe
Copying Platform Artifacts
Copying Database
Copying Licensefile
Copying Extensions
c:\bcartifacts.cache\tmp637428760545412940
Building image took 492 seconds
Using image 16-4-w1:sandbox-16.4.14693.19714-w1
Creating Container Kepty-Demo
Version: 16.4.14693.19714-W1
Style: sandbox
Platform: 16.0.14648.19648
Generic Tag: 0.1.0.24
Container OS Version: 10.0.18363.1198 (1909)
Host OS Version: 10.0.18363.1198 (1909)
Using locale en-US
Using process isolation
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Files in C:\ProgramData\NavContainerHelper\Extensions\Kepty-Demo\my:
- AdditionalOutput.ps1
- MainLoop.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container Kepty-Demo from image 16-4-w1:sandbox-16.4.14693.19714-w1
65926627a6741139fbf7346e415980f4bf79b5ab03350d0eed6366b78b5bfcc5
Waiting for container Kepty-Demo to be ready
Initializing...
Setting host.docker.internal to 10.0.0.5 in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to 10.0.0.5 in container hosts file (copy from host hosts file)
Setting kubernetes.docker.internal to 127.0.0.1 in container hosts file (copy from host hosts file)
Setting host.containerhelper.internal to 172.29.144.1 in container hosts file
Starting Container
Hostname is Kepty-Demo
PublicDnsName is Kepty-Demo
WARNING: DNS resolution not working from within the container.
Using NavUserPassword Authentication
Starting Local SQL Server
Starting Internet Information Server
Creating Self Signed Certificate
Self Signed Certificate Thumbprint 7EFE7BCF953F86A54D82DD84DF6790C5093F39AD
Modifying Service Tier Config File with Instance Specific Settings
Starting Service Tier
Registering event sources
Creating DotNetCore Web Server Instance
Enabling Financials User Experience
Creating http download site
Setting SA Password and enabling SA
Creating Kepty as SQL User and add to sysadmin
Creating SUPER user
WARNING: The password that you entered does not meet the minimum requirements. 
It should be at least 8 characters long and contain at least one uppercase 
letter, one lowercase letter, and one number.
Container IP Address: 172.29.144.157
Container Hostname  : Kepty-Demo
Container Dns Name  : Kepty-Demo
Web Client          : http://Kepty-Demo/BC/
Dev. Server         : http://Kepty-Demo
Dev. ServerInstance : BC
Setting Kepty-Demo to 172.29.144.157 in host hosts file

Files:
http://Kepty-Demo:8080/ALLanguage.vsix

Container Total Physical Memory is 15.9Gb
Container Free Physical Memory is 5.6Gb

Initialization took 145 seconds
Ready for connections!
Reading CustomSettings.config from Kepty-Demo
Creating Desktop Shortcuts for Kepty-Demo
Container Kepty-Demo successfully created


Days              : 0
Hours             : 0
Minutes           : 11
Seconds           : 2
Milliseconds      : 578
Ticks             : 6625789612
TotalDays         : 0,00766873797685185
TotalHours        : 0,184049711444444
TotalMinutes      : 11,0429826866667
TotalSeconds      : 662,5789612
TotalMilliseconds : 662578,9612

A that’s all! The container is created and is accessible through a link at the end of the report (for the example, the link to the web client is http://Kepty-Demo/BC)

If you want to find out more about the module “NavContainerHelper” see Freddy’s GitHub.

Recent Articles from the category

Connect to Business Central Container using VS Code

In the last article, we created our first Business Central Container for development. But how to use it within the VS Code environment? There is nothing special about the configuration. Just use values from message gained once the container was created. Use a value of...

read more

Sign Up for News

Certifications

Highest certification
Microsoft Data Management and
also in D365 Business Central

Microsoft Certified: Dynamics 365 Business Central Functional Consultant Associate

See other certifications here