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

Move-item error when creating new container #1215

Closed MikeGlue closed 4 years ago

MikeGlue commented 4 years ago

Describe the issue Receive the following error when trying to create a new container using BcContainerHelper: Move-Item : Cannot create a file when that file already exists. Scripts used to create container and cause the issue

$additionalParameters += "--env SqlTimeout=$sqltimeout"
$artifactUrl = 'https://bcartifacts.azureedge.net/sandbox/16.3.14085.14363/ca'
New-BCContainer -containerName mytestcontainer `
        -accept_eula `
        -accept_outdated `
        -auth NavUserPassword `
        -Credential $credential `
        -artifactUrl $artifactUrl `
        -imageName local `
        -licenseFile $licenseFile `
        -shortcuts desktop `
        -restart no `
        -updateHosts `
        -dns '8.8.8.8' `
        -useBestContainerOS `
        -includeAL `
        -enableTaskScheduler `
        -memoryLimit 10G `
        -useNewDatabase `
        -additionalParameters $additionalParameters

Full output of scripts

PS C:\WINDOWS\system32> C:\Users\mglue\OneDrive - Sparkrock\Powershell\Docker\Container\CreateContainer-SR365v2.ps1
Using custom license
BcContainerHelper is version 1.0.2
BcContainerHelper is running as administrator
Host is Microsoft Windows 10 Enterprise - 2004
Docker Client Version is 19.03.5
Docker Server Version is 19.03.5
ArtifactUrl and ImageName specified
Fetching all docker images
Downloading application artifact /sandbox/16.3.14085.14363/ca
Downloading C:\Users\mglue\AppData\Local\Temp\44454fb6-8102-406c-b61c-7abb78496ee5.zip
Unpacking application artifact to tmp folder using Expand-Archive
Image local:sandbox-16.3.14085.14363-ca-mt doesn't exist
Building multitenant image local:sandbox-16.3.14085.14363-ca-mt based on https://bcartifacts.azureedge.net/sandbox/16.3.14085.14363/ca
Building image local:sandbox-16.3.14085.14363-ca-mt based on mcr.microsoft.com/dynamicsnav:10.0.19041.388-generic
Pulling latest image mcr.microsoft.com/dynamicsnav:10.0.19041.388-generic
10.0.19041.388-generic: Pulling from dynamicsnav
295f12394c4f: Pulling fs layer
6754931bcbf3: Pulling fs layer
9d6b007da9d1: Pulling fs layer
31b3f3be70f7: Pulling fs layer
6005f49cc1ac: Pulling fs layer
0b656dbe1227: Pulling fs layer
c6279721d97d: Pulling fs layer
ba645d9e680c: Pulling fs layer
6005f49cc1ac: Waiting
44c09316837b: Pulling fs layer
70962c94d9e1: Pulling fs layer
894ad719cc97: Pulling fs layer
31b3f3be70f7: Waiting
0b656dbe1227: Waiting
c6279721d97d: Waiting
44c09316837b: Waiting
45e3e1a878c8: Pulling fs layer
ba645d9e680c: Waiting
70962c94d9e1: Waiting
894ad719cc97: Waiting
500d4653c6c9: Pulling fs layer
45e3e1a878c8: Waiting
179bb7aae132: Pulling fs layer
500d4653c6c9: Waiting
51e4826cff2e: Pulling fs layer
179bb7aae132: Waiting
775567551aec: Pulling fs layer
51e4826cff2e: Waiting
934a7cecd792: Pulling fs layer
775567551aec: Waiting
89b3763647be: Pulling fs layer
934a7cecd792: Waiting
c007250440e5: Pulling fs layer
89b3763647be: Waiting
b0e487c93946: Pulling fs layer
c007250440e5: Waiting
5f0e6a25d424: Pulling fs layer
b0e487c93946: Waiting
5f0e6a25d424: Waiting
9d6b007da9d1: Verifying Checksum
9d6b007da9d1: Download complete
31b3f3be70f7: Verifying Checksum
31b3f3be70f7: Download complete
6005f49cc1ac: Verifying Checksum
6005f49cc1ac: Download complete
0b656dbe1227: Verifying Checksum
0b656dbe1227: Download complete
c6279721d97d: Verifying Checksum
c6279721d97d: Download complete
ba645d9e680c: Verifying Checksum
ba645d9e680c: Download complete
44c09316837b: Verifying Checksum
44c09316837b: Download complete
70962c94d9e1: Verifying Checksum
70962c94d9e1: Download complete
894ad719cc97: Verifying Checksum
894ad719cc97: Download complete
6754931bcbf3: Retrying in 5 seconds
6754931bcbf3: Retrying in 4 seconds
6754931bcbf3: Retrying in 3 seconds
6754931bcbf3: Retrying in 2 seconds
6754931bcbf3: Retrying in 1 second
6754931bcbf3: Verifying Checksum
6754931bcbf3: Download complete
500d4653c6c9: Verifying Checksum
500d4653c6c9: Download complete
179bb7aae132: Verifying Checksum
179bb7aae132: Download complete
51e4826cff2e: Verifying Checksum
51e4826cff2e: Download complete
775567551aec: Verifying Checksum
775567551aec: Download complete
934a7cecd792: Verifying Checksum
934a7cecd792: Download complete
45e3e1a878c8: Retrying in 5 seconds
45e3e1a878c8: Retrying in 4 seconds
45e3e1a878c8: Retrying in 3 seconds
45e3e1a878c8: Retrying in 2 seconds
45e3e1a878c8: Retrying in 1 second
45e3e1a878c8: Verifying Checksum
45e3e1a878c8: Download complete
c007250440e5: Verifying Checksum
c007250440e5: Download complete
b0e487c93946: Verifying Checksum
b0e487c93946: Download complete
5f0e6a25d424: Verifying Checksum
5f0e6a25d424: Download complete
295f12394c4f: Verifying Checksum
295f12394c4f: Download complete
89b3763647be: Verifying Checksum
89b3763647be: Download complete
295f12394c4f: Pull complete
6754931bcbf3: Pull complete
9d6b007da9d1: Pull complete
31b3f3be70f7: Pull complete
6005f49cc1ac: Pull complete
0b656dbe1227: Pull complete
c6279721d97d: Pull complete
ba645d9e680c: Pull complete
44c09316837b: Pull complete
70962c94d9e1: Pull complete
894ad719cc97: Pull complete
45e3e1a878c8: Pull complete
500d4653c6c9: Pull complete
179bb7aae132: Pull complete
51e4826cff2e: Pull complete
775567551aec: Pull complete
934a7cecd792: Pull complete
89b3763647be: Pull complete
c007250440e5: Pull complete
b0e487c93946: Pull complete
5f0e6a25d424: Pull complete
Digest: sha256:fc7eb617914bce72ca0cdfc28e38e948614d0e14e951095285a4eb1129a38d95
Status: Downloaded newer image for mcr.microsoft.com/dynamicsnav:10.0.19041.388-generic
Generic Tag: 0.1.0.14
Container OS Version: 10.0.19041.388 (2004)
Host OS Version: 10.0.19041.423 (2004)
WARNING: Host OS and Base Image Container OS doesn't match and process isolation is specified. If you encounter issues, you could try to specify -isolation hyper
v
Using process isolation
Files in c:\bcartifacts.cache\tmp637327451261383997\my:
Downloading platform artifact /sandbox/16.3.14085.14363/platform
Downloading C:\Users\mglue\AppData\Local\Temp\0b67e76f-e685-4f8f-9c41-569feec8aace.zip
Unpacking platform artifact to tmp folder using Expand-Archive
Downloading Prerequisite Components
Downloading c:\bcartifacts.cache\sandbox\16.3.14085.14363\platform\Prerequisite Components\Open XML SDK 2.5 for Microsoft Office\OpenXMLSDKv25.msi
Downloading c:\bcartifacts.cache\sandbox\16.3.14085.14363\platform\Prerequisite Components\Microsoft Report Viewer 2015\ReportViewer.msi
Downloading c:\bcartifacts.cache\sandbox\16.3.14085.14363\platform\Prerequisite Components\IIS URL Rewrite Module\rewrite_2.0_rtw_x64.msi
Downloading c:\bcartifacts.cache\sandbox\16.3.14085.14363\platform\Prerequisite Components\Microsoft Report Viewer 2015\SQLSysClrTypes.msi
Downloading c:\bcartifacts.cache\sandbox\16.3.14085.14363\platform\Prerequisite Components\DotNetCore\DotNetCore.1.0.4_1.1.1-WindowsHosting.exe
Copying Platform Artifacts
Copying Database
Copying ConfigurationPackages
Copying Extensions
Copying Applications.ca
c:\bcartifacts.cache\tmp637327451261383997
Sending build context to Docker daemon  1.901GB

Step 1/6 : FROM mcr.microsoft.com/dynamicsnav:10.0.19041.388-generic
 ---> a2c32f8f325c
Step 2/6 : ENV DatabaseServer=localhost DatabaseInstance=SQLEXPRESS DatabaseName=CRONUS IsBcSandbox=Y artifactUrl=https://bcartifacts.azureedge.net/sandbox/16.3.
14085.14363/ca
 ---> Running in 05aafe3a6101
Removing intermediate container 05aafe3a6101
 ---> bf031e029828
Step 3/6 : COPY my /run/
 ---> 7efa3d38e492
Step 4/6 : COPY NAVDVD /NAVDVD/
 ---> 8df62bf8466b
Step 5/6 : RUN \Run\start.ps1 -installOnly -multitenant
 ---> Running in 351bea58b7d6
Using installer from C:\Run\150-new
Installing Business Central
Installing from DVD
Starting Local SQL Server
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
start...
Starting Internet Information Server
Copying Service Tier Files
Copying PowerShell Scripts
Copying dependencies
Copying ReportBuilder
Importing PowerShell Modules
Determining Database Collation
Restoring CRONUS Demo Database
Exporting Application to CRONUS
Removing Application from tenant
Modifying Business Central Service Tier Config File for Docker
Creating Business Central Service Tier
Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
Starting Business Central Service Tier
Copying Database on localhost\SQLEXPRESS from tenant to default
Taking database tenant offline
Copying database files
Attaching files as new Database default
Putting database tenant back online
Mounting tenant database
Mounting Database for default on server localhost\SQLEXPRESS
Sync'ing Tenant
Tenant is Operational
Stopping Business Central Service Tier
Copying Web Client Files
Copying Client Files
Copying ModernDev Files
Copying additional files
Copying ConfigurationPackages
Copying Test Assemblies
Copying Extensions
Copying Applications
Copying Applications.ca
Installation took 504 seconds
Installation complete
Removing intermediate container 351bea58b7d6
 ---> e7f95c62fb56
Step 6/6 : LABEL legal="http://go.microsoft.com/fwlink/?LinkId=837447"       created="202008111623"       nav=""       cu="update38"       multitenant="Y" countr
y="ca"       version="16.3.14085.14363"       platform="16.0.14073.14279"
 ---> Running in 4e4793196f49
Removing intermediate container 4e4793196f49
 ---> d483a749fe25
Successfully built d483a749fe25
Successfully tagged local:sandbox-16.3.14085.14363-ca-mt
Building image took 1768 seconds
Using image local:sandbox-16.3.14085.14363-ca-mt
Creating Container srsumm20ca
Version: 16.3.14085.14363-ca
Style: sandbox
Multitenant: Yes
Platform: 16.0.14073.14279
Generic Tag: 0.1.0.14
Container OS Version: 10.0.19041.388 (2004)
Host OS Version: 10.0.19041.423 (2004)
A better Generic Container OS exists for your host (mcr.microsoft.com/dynamicsnav:10.0.19041.388-generic)
Creating temp container from local:sandbox-16.3.14085.14363-ca-mt and extract necessary files
Extracting Service Tier and WebClient Files
Extracting Windows Client Files
Extracting Configuration packages
Extracting Test Assemblies
Extracting Test Toolkit
Extracting Upgrade Toolkit
Extracting Extensions
Extracting Applications
Extracting Applications.ca
Extracting Files from Run folder
Extracting Database Files
Downloading prerequisites
Downloading C:\ProgramData\BcContainerHelper\16.3.14085.14363-ca-Files\Prerequisite Components\IIS URL Rewrite Module\rewrite_2.0_rtw_x64.msi
Downloading C:\ProgramData\BcContainerHelper\16.3.14085.14363-ca-Files\Prerequisite Components\Open XML SDK 2.5 for Microsoft Office\OpenXMLSDKv25.msi
Downloading C:\ProgramData\BcContainerHelper\16.3.14085.14363-ca-Files\Prerequisite Components\DotNetCore\DotNetCore.1.0.4_1.1.1-WindowsHosting.exe
Performing cleanup
Move-Item : Cannot create a file when that file already exists.
At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\1.0.2\ContainerHandling\Extract-FilesFromStoppedNavContainer.ps1:137 char:13
+             Move-Item -Path (Get-Item "$path\databases\*.mdf").FullNa ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (C:\ProgramData\...sca_Primary.mdf:FileInfo) [Move-Item], IOException
    + FullyQualifiedErrorId : MoveFileInfoItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand

Move-Item : Cannot create a file when that file already exists.
At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\1.0.2\ContainerHandling\Extract-FilesFromStoppedNavContainer.ps1:138 char:13
+             Move-Item -Path (Get-Item "$path\databases\*.ldf").FullNa ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (C:\ProgramData\...sca_Primary.ldf:FileInfo) [Move-Item], IOException
    + FullyQualifiedErrorId : MoveFileInfoItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand

Screenshots n/a

Additional context

freddydk commented 4 years ago

Try without the usebestcontaineros

Hent Outlook til iOShttps://aka.ms/o0ukef


Fra: Mike Glue notifications@github.com Sendt: Tuesday, August 11, 2020 6:49:34 PM Til: microsoft/navcontainerhelper navcontainerhelper@noreply.github.com Cc: Freddy Kristiansen Freddy.Kristiansen@microsoft.com; Assign assign@noreply.github.com Emne: Re: [microsoft/navcontainerhelper] Move-item error when creating new container (#1215)

Assigned #1215https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fnavcontainerhelper%2Fissues%2F1215&data=02%7C01%7Cfreddy.kristiansen%40microsoft.com%7C939e07ab8fd342c31b5008d83e16887c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637327613780495132&sdata=R2y%2Fyuejs7CFV9FqksMycJHk1BnYSrYaN60g1Cf11Pc%3D&reserved=0 to @freddydkhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffreddydk&data=02%7C01%7Cfreddy.kristiansen%40microsoft.com%7C939e07ab8fd342c31b5008d83e16887c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637327613780495132&sdata=AokhtauClaLXgT7FknZuLh%2FusuX3uLZepLp3qjDmDuQ%3D&reserved=0.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fnavcontainerhelper%2Fissues%2F1215%23event-3644105379&data=02%7C01%7Cfreddy.kristiansen%40microsoft.com%7C939e07ab8fd342c31b5008d83e16887c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637327613780505079&sdata=KSQ21%2FV637vqGmcvIyFVXOx2kuUCOF1hajyVmnVHQC0%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACSGUA6BAWCQJT65ZAN63HDSAFZB3ANCNFSM4P3HWZ2A&data=02%7C01%7Cfreddy.kristiansen%40microsoft.com%7C939e07ab8fd342c31b5008d83e16887c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637327613780505079&sdata=q5%2FXGIGt8r7Q%2F5XOVW1r2zZibZ2WbqrzyT5Ts9Uase8%3D&reserved=0.

MikeGlue commented 4 years ago

Well, that eliminated the error above, but I get a new error now......

` PS C:\WINDOWS\system32> C:\Users\mglue\OneDrive - Sparkrock\Powershell\Docker\Container\CreateContainer-SR365v2.ps1 Using custom license Stopping existing container srsumm20ca srsumm20ca BcContainerHelper is version 1.0.2 BcContainerHelper is running as administrator Host is Microsoft Windows 10 Enterprise - 2004 Docker Client Version is 19.03.5 Docker Server Version is 19.03.5 Removing container srsumm20ca Removing srsumm20ca from host hosts file Removing C:\ProgramData\BcContainerHelper\Extensions\srsumm20ca ArtifactUrl and ImageName specified Fetching all docker images Image local:sandbox-16.3.14085.14363-ca-mt already exists Using image local:sandbox-16.3.14085.14363-ca-mt Creating Container srsumm20ca Version: 16.3.14085.14363-ca Style: sandbox Multitenant: Yes Platform: 16.0.14073.14279 Generic Tag: 0.1.0.14 Container OS Version: 10.0.19041.388 (2004) Host OS Version: 10.0.19041.423 (2004) WARNING: Host OS and Base Image Container OS doesn't match and process isolation is specified. If you encounter issues, you could try to specify -isolation hyper v Using process isolation Using locale en-CA Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable) Using license file C:_dev\bcLicense.flf Additional Parameters: --env SqlTimeout=10000 --env customNavSettings=EnableTaskScheduler=True Files in C:\ProgramData\BcContainerHelper\Extensions\srsumm20ca\my:

Setting host.containerhelper.internal to 172.27.144.1 in container hosts file Starting Container Hostname is srsumm20ca PublicDnsName is srsumm20ca Using NavUserPassword Authentication Starting Local SQL Server Starting Internet Information Server Creating Self Signed Certificate Self Signed Certificate Thumbprint DB8AA7AF2252F6E23C755A7370326A0F7B3CF980 Modifying Service Tier Config File with Instance Specific Settings Modifying Service Tier Config File with settings from environment variable Setting EnableTaskScheduler to True Starting Service Tier Registering event sources Creating DotNetCore Web Server Instance Enabling Financials User Experience Using license file 'c:\run\my\license.flf' Import License Creating http download site Setting SA Password and enabling SA Creating admin as SQL User and add to sysadmin Creating SUPER user The CRONUS database has version 0 which is not supported by this version of Microsoft Dynamics 365 Business Central Server. Please contact your administrator. at , C:\Run\SetupNavUsers.ps1: line 20 at , C:\Run\navstart.ps1: line 184 at , C:\Run\start.ps1: line 338 at , : line 1Error

Setting host.containerhelper.internal to 172.27.144.1 in container hosts file Starting Container Hostname is srsumm20ca PublicDnsName is srsumm20ca Using NavUserPassword Authentication Starting Local SQL Server Starting Internet Information Server Creating Self Signed Certificate Self Signed Certificate Thumbprint DB8AA7AF2252F6E23C755A7370326A0F7B3CF980 Modifying Service Tier Config File with Instance Specific Settings Modifying Service Tier Config File with settings from environment variable Setting EnableTaskScheduler to True Starting Service Tier Registering event sources Creating DotNetCore Web Server Instance Enabling Financials User Experience Using license file 'c:\run\my\license.flf' Import License Creating http download site Setting SA Password and enabling SA Creating admin as SQL User and add to sysadmin Creating SUPER user The CRONUS database has version 0 which is not supported by this version of Microsoft Dynamics 365 Business Central Server. Please contact your administrator. at , C:\Run\SetupNavUsers.ps1: line 20 at , C:\Run\navstart.ps1: line 184 at , C:\Run\start.ps1: line 338 at , : line 1 Initialization of container srsumm20ca failed At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\1.0.2\ContainerHandling\Wait-NavContainerReady.ps1:43 char:17

freddydk commented 4 years ago

Probably something with the usenewdatabase. Try -multitenant:$false - I have not tested the usenewdatabase with multitenant sandbox containers (will do that)

MikeGlue commented 4 years ago

turning off the multitenant option worked.

freddydk commented 4 years ago

There are a few issues here. -useBestContainerOS is used to replatform old images and should never be used when using artifacts. The reason why it fails is that a new windows update was shipped yesterday and the generic image for that isn't available yet (will be today) - and that it doesn't support multitenant images. Right now, I will clear the useBestContainerOS flag if using artifacts.

-useNewDatabase and -useCleanDatabase doesn't support multitenant images also. They do support switching to multitenancy, but not that the image is multitenant. I will fix this so that New-BcContainer uses a singletenant image and then keep the current functionality in useNew and useClean.

freddydk commented 4 years ago

Fix shipped in https://www.powershellgallery.com/packages/BcContainerHelper/1.0.3-preview156 Will be included in 1.0.3

freddydk commented 4 years ago

Shipped