microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
379 stars 243 forks source link

New container with restore bak file fails #1737

Closed peterz84 closed 3 years ago

peterz84 commented 3 years ago

Describe the issue When creating a container with parameter -bakFile I'm getting the error: There is insufficient free space on disk volume 'c:\' to create the database. The database requires 39904477184 additional free bytes, while only 20094226432 bytes are available.

Scripts used to create container and cause the issue

$artifactUrl = Get-BCArtifactUrl -country "nl" -version "17.1" -storageAccount bcartifacts -type “OnPrem” 
$credential = New-Object pscredential 'admin', (ConvertTo-SecureString -String 'P@ssword1' -AsPlainText -Force)
$containername = "BC17-1"
$backupFile = "D:\my3gbfile.bak"

New-BcContainer `
    -accept_eula `
    -containerName $containername `
    -artifactUrl $artifactUrl `
    -Credential $credential `
    -auth UserPassword `
    -updateHosts `
    -licenseFile $licenseFile `
    -bakFile $backupFile `

I tried with -isolation hyperv too, same error.

Full output of scripts

BcContainerHelper version 2.0.5
BcContainerHelper is version 2.0.5
BcContainerHelper is running as administrator
Host is Microsoft Windows 10 Pro - 2004
Docker Client Version is 20.10.2
Docker Server Version is 20.10.2
Removing BC17-1 from host hosts file
Removing BC17-1-* from host hosts file
Removing C:\ProgramData\BcContainerHelper\Extensions\BC17-1
Fetching all docker images
Using image mcr.microsoft.com/businesscentral:10.0.19041.804
Creating Container BC17-1
Version: 17.1.18256.18792-nl
Style: onprem
Multitenant: No
Platform: 17.0.18204.18738
Generic Tag: 1.0.1.3
Container OS Version: 10.0.19041.804 (2004)
Host OS Version: 10.0.19041.804 (2004)
Using hyperv isolation
Using locale nl-NL
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Files in C:\ProgramData\BcContainerHelper\Extensions\BC17-1\my:
- AdditionalOutput.ps1
- MainLoop.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container BC17-1 from image mcr.microsoft.com/businesscentral:10.0.19041.804
741aead87640329807db0b92d81f29db0ae0a7ebebe356499c661cea8b5429b8
Waiting for container BC17-1 to be ready
Using artifactUrl https://bcartifacts.azureedge.net/onprem/17.1.18256.18792/nl
Using installer from C:\Run\150-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
Copying PowerShell Scripts
Copying dependencies
Copying ReportBuilder
Importing PowerShell Modules
Skipping restore of Cronus database
Modifying Business Central Service Tier Config File for Docker
Creating Business Central Service Tier
Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
Copying Web Client Files
Copying Client Files
Copying ModernDev Files
Copying additional files
Copying ConfigurationPackages
Copying Test Assemblies
Copying Applications
Installation took 32 seconds
Installation complete
Initializing...
Setting host.docker.internal to 192.168.1.25 in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to 192.168.1.25 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.18.0.1 in container hosts file
Starting Container
Hostname is BC17-1
PublicDnsName is BC17-1
WARNING: DNS resolution not working from within the container.
WARNING: Container starts with TimeZone = West-Europa (standaardtijd), which is not recognized in the list of TimeZones.
Using NavUserPassword Authentication
Using Database .bak file 'C:\ProgramData\BcContainerHelper\Extensions\BC17-1\database.bak'
Using database server localhost\SQLEXPRESS
The database restore operation failed due to the following error returned by SQL Server:
There is insufficient free space on disk volume 'c:\' to create the database. The database requires 39904477184 additional free bytes, while only 20094226432 bytes are available.
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
RESTORE DATABASE is terminating abnormally.
at <ScriptBlock>, C:\Run\SetupDatabase.ps1: line 54
at <ScriptBlock>, C:\Run\navstart.ps1: line 121
at <ScriptBlock>, C:\Run\start.ps1: line 359
at <ScriptBlock>, <No file>: line 1Error
Using artifactUrl https://bcartifacts.azureedge.net/onprem/17.1.18256.18792/nl
Using installer from C:\Run\150-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
Copying PowerShell Scripts
Copying dependencies
Copying ReportBuilder
Importing PowerShell Modules
Skipping restore of Cronus database
Modifying Business Central Service Tier Config File for Docker
Creating Business Central Service Tier
Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
Copying Web Client Files
Copying Client Files
Copying ModernDev Files
Copying additional files
Copying ConfigurationPackages
Copying Test Assemblies
Copying Applications
Installation took 32 seconds
Installation complete
Initializing...
Setting host.docker.internal to 192.168.1.25 in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to 192.168.1.25 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.18.0.1 in container hosts file
Starting Container
Hostname is BC17-1
PublicDnsName is BC17-1
WARNING: DNS resolution not working from within the container.
WARNING: Container starts with TimeZone = West-Europa (standaardtijd), which is not recognized in the list of TimeZones.
Using NavUserPassword Authentication
Using Database .bak file 'C:\ProgramData\BcContainerHelper\Extensions\BC17-1\database.bak'
Using database server localhost\SQLEXPRESS
The database restore operation failed due to the following error returned by SQL Server:
There is insufficient free space on disk volume 'c:\' to create the database. The database requires 39904477184 additional free bytes, while only 20094226432 bytes are available.
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
RESTORE DATABASE is terminating abnormally.
at <ScriptBlock>, C:\Run\SetupDatabase.ps1: line 54
at <ScriptBlock>, C:\Run\navstart.ps1: line 121
at <ScriptBlock>, C:\Run\start.ps1: line 359
at <ScriptBlock>, <No file>: line 1
Initialization of container BC17-1 failed
At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.5\ContainerHandling\Wait-NavContainerReady.ps1:43 char:17
+ ...             throw "Initialization of container $containerName failed" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Initialization ...r BC17-1 failed:String) [], RuntimeException
    + FullyQualifiedErrorId : Initialization of container BC17-1 failed

Additional context Occurring on multiple machines. I have 36gb of free space on my c drive.

tfenster commented 3 years ago

The error message looks weird but if I calculate correctly, then this is a 38G database which is above the limit of 10G for SQL Express used in the BC images

peterz84 commented 3 years ago

That might indeed be a problem. Not sure if it's the problem indicated in the error message above. Could be something with harddisk allocation because of the bak file being compressed?

tfenster commented 3 years ago

Yes, there is also a general limit of how much disk space a container can have by default which might also be a complication. But anyway, you won't be able to use the SQL Server in the container for that because of the 10G limit

freddydk commented 3 years ago

Yeah, for bigger databases use SQL on the host or on a separate machine, but there is a limit on containers disk space. The below is dir inside a container and dir on the host where that container is hosted. Even though it is process isolation, the container has 17G available and the host has 205G image

peterz84 commented 3 years ago

Got it. Using SQL on the host now (thanks to your blog :))