microsoft / navcontainerhelper

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

Copy-FileToBcContainer: The background process repoted an error with the following message: "The named pipe target process has ended." #2676

Closed wbrakowski closed 2 years ago

wbrakowski commented 2 years ago

PLEASE DO NOT INCLUDE ANY PASSWORDS OR TOKENS IN YOUR ISSUE!!!

Describe the issue

Hello Freddy. I am having trouble using the command Copy-FileToBcContainer. The creation of my container succeeds without problems. I need to copy a lot of dlls from a local folder to the addin folder of my container. I created a script for the copying of the dlls and it worked fine on another laptop, but after trying the same scripts with a new laptop I am getting errors.

To clarify: Copying one file from local folder to the container folder works perfectly fine. The script often even copies 50-100 dll files without problems, but after a while I always receive the error: "The background process repoted an error with the following message: "The named pipe target process has ended."

...sometimes after 10 files were copied, sometimes after 100 files were copied. It is not tied to a specific file.

Do you have an idea what I might be doing wrong? Or any idea what I can do instead to copy these many dlls to my container?

Scripts used to create container and cause the issue

NOTE: The creation of the container is not the problem!

$containerName = 'packcarrytest2'
$password = 'P@ssw0rd'
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force
$credential = New-Object pscredential 'admin', $securePassword
$auth = 'UserPassword'
$artifactUrl = Get-BcArtifactUrl -type 'OnPrem' -version '20.3' -country 'de' 
New-BcContainer `
    -accept_eula `
    -containerName $containerName `
    -credential $credential `
    -auth $auth `
    -artifactUrl $artifactUrl `
    -updateHosts
...

Full output of scripts

PS C:\Windows\system32> G:\Other computers\Mein Laptop\Arbeit\Prog\Business Central\Pack & Carry\packcarry.ps1
BcContainerHelper version 4.0.0
BcContainerHelper emits usage statistics telemetry to Microsoft
BcContainerHelper is version 4.0.0
BcContainerHelper is running as administrator
Hyper-V is Enabled
UsePsSession is True
Host is Microsoft Windows 10 Pro - 21H1
Docker Client Version is 20.10.17
Docker Server Version is 20.10.17
Removing Desktop shortcuts
Fetching all docker images
Fetching all docker volumes
INFO: Windows 10 21H1/21H2 images are not yet available, using 2004 as these are found to work better than 20H2 on 21H1/21H2
Using image mcr.microsoft.com/businesscentral:10.0.19041.1415
Creating Container packcarrytest2
Style: onprem
Multitenant: No
Version: 20.3.42673.43026
Platform: 20.0.42653.43007
Generic Tag: 1.0.2.13
Container OS Version: 10.0.19041.1415 (2004)
Host OS Version: 10.0.19043.1889 (21H1)
WARNING: Host OS is 21H1 and Container OS is 2004, defaulting to process isolation. If you experience problems, add -isolation hyperv.
Using process isolation
Using locale de-DE
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Files in C:\ProgramData\BcContainerHelper\Extensions\packcarrytest2\my:
- AdditionalOutput.ps1
- MainLoop.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container packcarrytest2 from image mcr.microsoft.com/businesscentral:10.0.19041.1415
afe313ec35308782f5fdd452480a807727f2e2ee63295af418e3882b2a09d7c5
Waiting for container packcarrytest2 to be ready
Using artifactUrl https://bcartifacts.azureedge.net/onprem/20.3.42673.43026/de
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
c:\dl\onprem\20.3.42673.43026\platform\ServiceTier\Program Files
c:\dl\onprem\20.3.42673.43026\platform\ServiceTier\System64Folder
Copying PowerShell Scripts
c:\dl\onprem\20.3.42673.43026\platform\WindowsPowerShellScripts\Cloud\NAVAdministration
c:\dl\onprem\20.3.42673.43026\platform\WindowsPowerShellScripts\WebSearch
Copying Web Client Files
c:\dl\onprem\20.3.42673.43026\platform\WebClient\Microsoft Dynamics NAV
Copying Client Files
c:\dl\onprem\20.3.42673.43026\platform\LegacyDlls\program files\Microsoft Dynamics NAV
c:\dl\onprem\20.3.42673.43026\platform\LegacyDlls\program files\Microsoft Dynamics NAV
c:\dl\onprem\20.3.42673.43026\platform\LegacyDlls\systemFolder
Copying ModernDev Files
c:\dl\onprem\20.3.42673.43026\platform
c:\dl\onprem\20.3.42673.43026\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\onprem\20.3.42673.43026\de\ConfigurationPackages
Copying Test Assemblies
C:\dl\onprem\20.3.42673.43026\platform\Test Assemblies
Copying Applications
C:\dl\onprem\20.3.42673.43026\de\Applications
Copying dependencies
Copying ReportBuilder
Using artifactUrl https://bcartifacts.azureedge.net/onprem/20.3.42673.43026/de
Using installer from 
Installing Business Central
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
c:\dl\onprem\20.3.42673.43026\platform\ServiceTier\Program Files
c:\dl\onprem\20.3.42673.43026\platform\ServiceTier\System64Folder
Copying PowerShell Scripts
c:\dl\onprem\20.3.42673.43026\platform\WindowsPowerShellScripts\Cloud\NAVAdministration
c:\dl\onprem\20.3.42673.43026\platform\WindowsPowerShellScripts\WebSearch
Copying Web Client Files
c:\dl\onprem\20.3.42673.43026\platform\WebClient\Microsoft Dynamics NAV
Copying Client Files
c:\dl\onprem\20.3.42673.43026\platform\LegacyDlls\program files\Microsoft Dynamics NAV
c:\dl\onprem\20.3.42673.43026\platform\LegacyDlls\program files\Microsoft Dynamics NAV
c:\dl\onprem\20.3.42673.43026\platform\LegacyDlls\systemFolder
Copying ModernDev Files
c:\dl\onprem\20.3.42673.43026\platform
c:\dl\onprem\20.3.42673.43026\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\onprem\20.3.42673.43026\de\ConfigurationPackages
Copying Test Assemblies
C:\dl\onprem\20.3.42673.43026\platform\Test Assemblies
Copying Applications
C:\dl\onprem\20.3.42673.43026\de\Applications
Copying dependencies
Copying ReportBuilder
Importing PowerShell Modules
Restoring CRONUS Demo Database
Setting CompatibilityLevel for CRONUS on localhost\SQLEXPRESS
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
Importing license file
Stopping Business Central Service Tier
Installation took 71 seconds
Installation complete
Initializing...
Setting host.docker.internal to 192.168.178.61 in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to 192.168.178.61 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.192.1 in container hosts file
Starting Container
Hostname is packcarrytest2
PublicDnsName is packcarrytest2
Using NavUserPassword Authentication
Creating Self Signed Certificate
Self Signed Certificate Thumbprint F8C23CDBC02552509A710814369405240571AF49
DNS identity packcarrytest2
Modifying Service Tier Config File with Instance Specific Settings
Starting Service Tier
Registering event sources
Creating DotNetCore Web Server Instance
Using application pool name: BC
Using default container name: NavWebApplicationContainer
Copy files to WWW root C:\inetpub\wwwroot\BC
Create the application pool BC
Create website: NavWebApplicationContainer without SSL
Update configuration: navsettings.json
Done Configuring Web Client
Creating http download site
Setting SA Password and enabling SA
Creating admin as SQL User and add to sysadmin
Creating SUPER user
Container IP Address: 172.29.207.253
Container Hostname  : packcarrytest2
Container Dns Name  : packcarrytest2
Web Client          : http://packcarrytest2/BC/
Dev. Server         : http://packcarrytest2
Dev. ServerInstance : BC
Setting packcarrytest2 to 172.29.207.253 in host hosts file

Files:
http://packcarrytest2:8080/ALLanguage.vsix

WARNING: You are running a container which is 180 days old.
Microsoft recommends that you always run the latest version of our containers.

Container Total Physical Memory is 15.7Gb
Container Free Physical Memory is 4.3Gb

Initialization took 51 seconds
Ready for connections!
Reading CustomSettings.config from packcarrytest2
Creating Desktop Shortcuts for packcarrytest2
Container packcarrytest2 successfully created
Health check returns False, restarting container
Removing Session packcarrytest2
packcarrytest2
Waiting for container packcarrytest2 to be ready

Initializing...
Setting host.docker.internal to 192.168.178.61 in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to 192.168.178.61 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.192.1 in container hosts file
Restarting Container
PublicDnsName unchanged
Hostname is packcarrytest2
PublicDnsName is packcarrytest2
Using NavUserPassword Authentication
Starting Local SQL Server
Starting Internet Information Server
Starting Service Tier
Container IP Address: 172.29.192.147
Container Hostname  : packcarrytest2
Container Dns Name  : packcarrytest2
Web Client          : http://packcarrytest2/BC/
Dev. Server         : http://packcarrytest2
Dev. ServerInstance : BC
Setting packcarrytest2 to 172.29.192.147 in host hosts file

Files:
http://packcarrytest2:8080/ALLanguage.vsix

Container Total Physical Memory is 15.7Gb
Container Free Physical Memory is 4.3Gb

Initialization took 14 seconds
Ready for connections!

Use:
Get-BcContainerEventLog -containerName packcarrytest2 to retrieve a snapshot of the event log from the container
Get-BcContainerDebugInfo -containerName packcarrytest2 to get debug information about the container
Enter-BcContainer -containerName packcarrytest2 to open a PowerShell prompt inside the container
Remove-BcContainer -containerName packcarrytest2 to remove the container again
docker logs packcarrytest2 to retrieve information about URL's again

PS C:\Windows\system32> 
...

This is the script I use to copy files to the container

$containerName = 'packcarrytest2'
$bcAddInFolder = 'C:\Program Files\Microsoft Dynamics NAV\200\service\add-ins\tso'
$localAddinFolder = 'C:\Users\walde\Downloads\AddInsPackageContent\.AddInsPackageContent\'
$dlls = Get-ChildItem $localAddinFolder* -Recurse -Include '*.dll'

foreach ($dll in $dlls) {
    $fileName = Split-Path $dll -leaf
    Copy-FileToNavContainer  -containerName $containerName -localPath $dll -containerPath (Join-Path -Path $bcAddInFolder $fileName) 
}

Enter-NavContainer -containerName $containerName

cd $bcAddInFolder

Set-NavServerInstance -ServerInstance BC -Restart

Screenshots image

Additional context

freddydk commented 2 years ago

You should consider sharing the files to the container instead of copying. What are you trying to achieve? if you have a number of files you want to copy to the add-ins folder, I think you can add this to the new-bccontainer command: -additionalparameters @( "--volume c:\run\add-ins:c:\folderonlocalcomputer")

wbrakowski commented 2 years ago

Thank you for the fast response. Like this?

image

That did not work for me.

image