Starting in 2019 I found learning increasingly more about Docker and Microsoft Powershell libraries that get you a running instance of NAV or Business Central in a local container.
I am going to investigate 3 ways that get you a running NAV/BC container.
1. Using pure docker command
You can start with Docker here.
Example of using docker to create first BC container:
docker run -e accept_eula=y mcr.microsoft.com/businesscentral/sandbox
This command will set an environment variable local to the new container and will pull (if not already pulled) the image specified (mcr.microsoft.com/businesscentral/sandbox) and will run it.
You could also run the container based on a Business Central image for Windows Server 2019. This is a lighter image than the previous one which was for Windows 10 OS.
docker run -e accept_eula=y mcr.microsoft.com/businesscentral/sandbox:ltsc2019
To check the size of the images downloaded run from the command prompt:
docker image list
If you want to delete some of your images run for each the following:
docker image rm 0d -f
You can specify the whole identifier for the image or just the first 2 letters (0d).
With the container running, you can open VS Code, install AL code using the ALLanguage.vsix from the location displayed in the log:
If you have trouble using the dns name, something must not have been right with writing the hosts file, but you could always use the IP of the container.
Now you should be able to connect to your container and start writing extensions.
2.Using Microsoft’s module NAVContainerHelper, more specifically “New-NAVContainer” command:
New-NavContainer -accept_eula -containerName “firstcontainer” -auth Windows -imageName mcr.microsoft.com/businesscentral/sandbox:ltsc2019
While previous command could have been launched from the command prompt (with docker running), you can launch the above command from the prompt of Powershell ISE (run as admin). This will pull the latest business central image for Windows Server 2019. If you run “docker image ls” you can notice this is a lighter image.
You can connect to that instance to write extensions by running VS Code and installing vsix file that comes with the container.
3. Using Microsoft’s module BcContainerHelper.
Latest Microsoft’s module, BCContainerHelper has a command New_BCContainerWizzard. This command generates a Powershell script that, when run, creates a NAV/BC container.
To gain access to the wizzard, install first the new module BCContainerHelper. When running “Install-Module -Name BcContainerHelper” I had an error:
Then I added the “-AllowClobber” parameter and module was successfully installed.
Install-Module -Name BcContainerHelper -AllowClobber
Once BcContainerHelper installed I had access to the New-BcContainerWizzard:
Let’s launch it and install a container loaded with a NAV 2017 CU5 image:
- Accept Eula:
Choose Y.
2. Next we need to choose between a locally stored container or a container stored in Azure:
Default is Local and that’s what I chose.
3. For authentication step you have a few options: either username + password or Windows. I choose Windows:
4. Name container:
5. Version: latest BC (onprem or Sandbox) or a specific version.
We are going to install a container with an OnPrem image of NAV 2017 CU5. For a list of sandboxes and onprem images consult these links:
https://mcr.microsoft.com/v2/businesscentral/sandbox/tags/list
https://mcr.microsoft.com/v2/businesscentral/onprem/tags/list
6. Country
I chose NA.
7. Test toolkit ?
10. License (No, or local file or https url for downloading the license file)
11. Database: you can leave the new container loaded with cronus db in a local (to container) sqlexpress instance or you can load a database with the correct version in the SQLExpress instance or use a SQL Server other than container’s SQL Server. I chose the default but planning to connect to the SQL Server express instance and restore a backup later once container is created and runs.
12. DNS settings:
13. Memory Limit:
I left default.
14. CAL Development:
As it is a NAV 2017 image I chose Yes.
Name and save your powershell script:
The window will close and a Powershell ISE opens with the new script:
Now you can distribute the script with your team. If you want to generate the new container press F5.
In the script please note the new parameter artifactURL. More on this new parameter here.
After 835 seconds the container was installed. However during the last steps (exporting shortcuts to host desktop) script encountered an error:
In the version of BcContainerHelper I was working with (1.0.1) , Export-BcContainerObjects was not included. In fact, the command should have been Export-NAVContainerObjects.
I created the issue in github and next day I found an email from Freddy that this was a bug and it will be shipped in BcContainerHelper 1.0.2-preview153.
As the new release was available, I re-installed the module and I was able to finish running the script.
I needed a current version of the database instead of installed Cronus database, so I connected via SSMS to the container SQL instance and restored the database. Now development can take place in the container.
One Response