Closed Pavel-Titov closed 4 years ago
So you started by using New-NavContainer to create your bc15knk container? Then you save (commit) the fully functional bc15knk container and push it to docker hub?
Not tried it my self, but I would think that you don't need to use New-NavContainer to start it again. Instead you should be able to use docker run directly. It may work if you test it using the same machine you created it on, but I doubt that it would work if you use a different docker host. The reason for that is that a NavContainer have a lot of additional setup, which NavContainerHelper creates for each host. But why is it that you cannot use the standard images? If it's because you need it pre-configured with demo-data etc. then just use the standard images plus a backup. Freddy has described how to do this in his blog around November 2019.
Hi @epernst Yes, the main reason that the database contains the demodata. Sure, I can make a backup from container and use it to create a new one... Also my container already contains all necessary dlls for dotnet controls for proper function. I want just establish the simple and easy way for DEV and QA to create their environment with one powershell command. I think somewhere in October 2019 I tested the same way and it worked fine. Could it be because of some modifications in the NavContainerHelper?
We have the same issue, our developers need to get the latest and greatest version of our solution (sometimes multiple times per day). So we let our Azure DevOps build pipeline handle it. As part of our build, we create a new database, incl. demo data and published dependency applications. Together with DotNet controls we package this as a Nuget package. This way our developer can download the package and run our script (new-navcontainer, restore db and share dotnet with container). It was actually the post in December I thought about: https://freddysblog.com/2019/12/09/having-demo-data-while-developing-business-central-apps-with-docker/
Thanks,, @epernst! Yes, sure, developer can run almost the same script I used to create the container from SQL backup, but I was just thinking why the restoring from the docker hub does not work for me... although I believe it should... as I understood the collision in case of new-navcontainer happens, because the existing file cannot be deleted by the following command in NAVWebClientManagement.psm1 (line 562):
if (Test-Path $siteRootFolder) {
Write-Verbose "Remove $siteRootFolder"
**Remove-Item $siteRootFolder -Recurse -Force**
}
although when I run the same command directly from the container (once the preparation is failed) the file is deleted, so I assume that happens that the Webserver is already running and locking the file...
It is possible to commit and recreate containers, but it isn't really a supported scenario for NAV/BC containers. You can do a lot of stuff this makes this hard or not possible.
The specific error above might go away if you switch to hyperv isolation, but I still wouldn't recommend the path you are heading down.
A few other issues related to this: https://github.com/microsoft/navcontainerhelper/issues/525 https://github.com/microsoft/navcontainerhelper/issues/754
If you want to create your own images, you can see how this is done using docker build here: https://github.com/microsoft/nav-docker/tree/master/bc-local (this shows how to build a local version of BC based on a W1 image) You could create a DOCKERFILE and create your image based on a local or W1 image.
The simplest and fastest way is to use database backups, there are a lot of options for doing that. You can also place the database on the host and have it running at all times (and/or restore using PS)
Ok, we will follow your recommendations and will create a container from SQL backup instead of the DockerHub repository. Thanks!
Hi all, I am facing the following problems when creating the container from my own repo:
also when I am trying to create a container from docker command:
I built the image by the following command set: