microsoft / navcontainerhelper

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

Access to the path 'c:\driversetc\hosts' is denied. #1922

Closed rarrese closed 3 years ago

rarrese commented 3 years ago

Hi Freddy,

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

Describe the issue

I´m running the CreateBCSandbox.ps1 whith -version '18.0.23013.23532' -country 'MX' -select 'Closest'; the error message is:

Sync'ing Tenant Tenant is Operational Stopping Business Central Service Tier Installation took 1256 seconds Installation complete Initializing... Exception calling "Open" with "4" argument(s): "Access to the path 'c:\driversetc\hosts' is denied." at UpdateHostsFile, C:\Run\my\updatehosts.ps1: line 20 at , C:\Run\my\updatehosts.ps1: line 116 at , C:\Run\my\SetupVariables.ps1: line 5 at , C:\Run\navstart.ps1: line 24 at , C:\Run\start.ps1: line 363 at , : line 1 Initialization of container ErroTrustContainer failed En C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.11\ContainerHandling\Wait-NavContainerReady.ps1: 43 Carácter: 17

Scripts used to create container and cause the issue

# set accept_eula to $true to accept the eula found here: https://go.microsoft.com/fwlink/?linkid=861843
$accept_eula = $true
$containername = 'ErroTrustContainer'
$licenseFile = ''
$auth = 'Windows'
$usessl = $false
$updateHosts = $true
$assignPremiumPlan = $true
$shortcuts = 'Desktop'

$artifactUrl = Get-BcArtifactUrl -version '18.0.23013.23532' -country 'MX' -select 'Closest'

if ($auth -eq 'Windows') {
    $credential = get-credential -UserName $env:USERNAME -Message 'Using Windows Authentication. Please enter your Windows credentials.'
}
elseif ($auth -eq 'UserPassword') {
    $credential = get-credential -Message 'Using Username/Password Authentication. Please enter credentials.'
}
else {
    throw '$auth needs to be either Windows or UserPassword'
}

if (!$accept_eula) {
    throw 'You have to accept the eula in order to create a Container.'
}
if (!($containername)) {
    throw 'You have to specify a container name in order to create a container.'
}
if (!($artifactUrl)) {
    throw 'No matching build was found for your version of Business Central'
}
New-BcContainer -accept_eula:$accept_eula `
                -containername $containername `
                -artifactUrl $artifactUrl `
                -auth $auth `
                -Credential $credential `
                -usessl:$usessl `
                -updateHosts:$updateHosts `
                -licenseFile $licenseFile `
                -assignPremiumPlan:$assignPremiumPlan `
                -shortcuts $shortcuts

if ($licenseFile) {
    Setup-BcContainerTestUsers -containerName $containername -password $credential.Password
}

Full output of scripts

BcContainerHelper version 2.0.11
WARNING: Container name should not exceed 15 characters
BcContainerHelper is version 2.0.11
BcContainerHelper is running as administrator
Host is Microsoft Windows 10 Pro - 2004
Docker Client Version is 20.10.5
Docker Server Version is 20.10.5
Removing ErroTrustContainer from container hosts file
Removing ErroTrustContainer-* from container hosts file
Removing C:\ProgramData\BcContainerHelper\Extensions\ErroTrustContainer
Fetching all docker images
Fetching all docker volumes
Pulling image mcr.microsoft.com/businesscentral:10.0.19041.928
10.0.19041.928: Pulling from businesscentral
295f12394c4f: Pulling fs layer
2d44bfce6197: Pulling fs layer
139497e00fa9: Pulling fs layer
cce5d28dbbe0: Pulling fs layer
48d27b5fb124: Pulling fs layer
cce5d28dbbe0: Waiting
48d27b5fb124: Waiting
58d4ad761f39: Pulling fs layer
ddcee573fef9: Pulling fs layer
58d4ad761f39: Waiting
2757c90676c0: Pulling fs layer
ddcee573fef9: Waiting
0d70e0b2e5f8: Pulling fs layer
0d70e0b2e5f8: Waiting
828ae02ca5b9: Pulling fs layer
2757c90676c0: Waiting
6ae1febacfae: Pulling fs layer
828ae02ca5b9: Waiting
de4a9854c853: Pulling fs layer
39b0fd06e13c: Pulling fs layer
09b21f74a2e9: Pulling fs layer
dd09aa96b8fd: Pulling fs layer
4b7f296bd2b0: Pulling fs layer
9a2d98be0721: Pulling fs layer
6ae1febacfae: Waiting
de4a9854c853: Waiting
39b0fd06e13c: Waiting
09b21f74a2e9: Waiting
dd09aa96b8fd: Waiting
4b7f296bd2b0: Waiting
9a2d98be0721: Waiting
139497e00fa9: Verifying Checksum
139497e00fa9: Download complete
295f12394c4f: Retrying in 5 seconds
295f12394c4f: Retrying in 4 seconds
295f12394c4f: Retrying in 3 seconds
295f12394c4f: Retrying in 2 seconds
295f12394c4f: Retrying in 1 second
2d44bfce6197: Retrying in 5 seconds
cce5d28dbbe0: Verifying Checksum
cce5d28dbbe0: Download complete
2d44bfce6197: Retrying in 4 seconds
2d44bfce6197: Retrying in 3 seconds
48d27b5fb124: Verifying Checksum
48d27b5fb124: Download complete
2d44bfce6197: Retrying in 2 seconds
2d44bfce6197: Retrying in 1 second
58d4ad761f39: Verifying Checksum
58d4ad761f39: Download complete
ddcee573fef9: Verifying Checksum
ddcee573fef9: Download complete
2757c90676c0: Verifying Checksum
2757c90676c0: Download complete
0d70e0b2e5f8: Verifying Checksum
0d70e0b2e5f8: Download complete
828ae02ca5b9: Verifying Checksum
828ae02ca5b9: Download complete
2d44bfce6197: Verifying Checksum
2d44bfce6197: Download complete
de4a9854c853: Verifying Checksum
de4a9854c853: Download complete
39b0fd06e13c: Verifying Checksum
39b0fd06e13c: Download complete
09b21f74a2e9: Verifying Checksum
09b21f74a2e9: Download complete
dd09aa96b8fd: Verifying Checksum
dd09aa96b8fd: Download complete
4b7f296bd2b0: Verifying Checksum
4b7f296bd2b0: Download complete
9a2d98be0721: Verifying Checksum
9a2d98be0721: Download complete
295f12394c4f: Verifying Checksum
295f12394c4f: Download complete
6ae1febacfae: Verifying Checksum
6ae1febacfae: Download complete
295f12394c4f: Pull complete
2d44bfce6197: Pull complete
139497e00fa9: Pull complete
cce5d28dbbe0: Pull complete
48d27b5fb124: Pull complete
58d4ad761f39: Pull complete
ddcee573fef9: Pull complete
2757c90676c0: Pull complete
0d70e0b2e5f8: Pull complete
828ae02ca5b9: Pull complete
6ae1febacfae: Pull complete
de4a9854c853: Pull complete
39b0fd06e13c: Pull complete
09b21f74a2e9: Pull complete
dd09aa96b8fd: Pull complete
4b7f296bd2b0: Pull complete
9a2d98be0721: Pull complete
Digest: sha256:540e63316c6cbf88ab2d9dbb53dbdb62bc1ec8fde8090b8cbcb34f4c00101307
Status: Downloaded newer image for mcr.microsoft.com/businesscentral:10.0.19041.928
mcr.microsoft.com/businesscentral:10.0.19041.928
Using image mcr.microsoft.com/businesscentral:10.0.19041.928
Creating Container ErroTrustContainer
Version: 18.0.23013.23795-MX
Style: sandbox
Multitenant: Yes
Platform: 18.0.22893.23773
Generic Tag: 1.0.1.6
Container OS Version: 10.0.19041.928 (2004)
Host OS Version: 10.0.19041.928 (2004)
Using process isolation
Using locale es-MX
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Files in C:\ProgramData\BcContainerHelper\Extensions\ErroTrustContainer\my:
- AdditionalOutput.ps1
- MainLoop.ps1
- SetupNavUsers.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container ErroTrustContainer from image mcr.microsoft.com/businesscentral:10.0.19041.928
626781f5fa0d319fe1dc19209f941bca773a26f097b529ddc5be6863d130d506
Waiting for container ErroTrustContainer to be ready
Adding ERROTRUSTCONTAI to hosts file
Using artifactUrl https://bcartifacts.azureedge.net/sandbox/18.0.23013.23795/mx
Using installer from C:\Run\150-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
start...
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
start...
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
start...
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
start...
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
start...
Starting Internet Information Server
Copying Service Tier Files
c:\dl\sandbox\18.0.23013.23795\platform\ServiceTier\Program Files
c:\dl\sandbox\18.0.23013.23795\platform\ServiceTier\System64Folder
Copying PowerShell Scripts
c:\dl\sandbox\18.0.23013.23795\platform\WindowsPowerShellScripts\Cloud\NAVAdministration
c:\dl\sandbox\18.0.23013.23795\platform\WindowsPowerShellScripts\WebSearch
Copying dependencies
Copying ReportBuilder
Importing PowerShell Modules
Determining Database Collation from c:\dl\sandbox\18.0.23013.23795\mx\BusinessCentral-MX.bak
Changing Database Server Collation to Modern_Spanish_100_CS_AS
Restoring CRONUS Demo Database
Setting CompatibilityLevel for tenant on localhost\SQLEXPRESS
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'
Copying Web Client Files
c:\dl\sandbox\18.0.23013.23795\platform\WebClient\Microsoft Dynamics NAV
Copying Client Files
c:\dl\sandbox\18.0.23013.23795\platform\LegacyDlls\program files\Microsoft Dynamics NAV
c:\dl\sandbox\18.0.23013.23795\platform\LegacyDlls\program files\Microsoft Dynamics NAV
c:\dl\sandbox\18.0.23013.23795\platform\LegacyDlls\systemFolder
Copying ModernDev Files
c:\dl\sandbox\18.0.23013.23795\platform
c:\dl\sandbox\18.0.23013.23795\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\sandbox\18.0.23013.23795\platform\ConfigurationPackages
Copying Test Assemblies
C:\dl\sandbox\18.0.23013.23795\platform\Test Assemblies
Copying Extensions
C:\dl\sandbox\18.0.23013.23795\mx\Extensions
Copying Applications
C:\dl\sandbox\18.0.23013.23795\platform\Applications
Copying Applications.MX
C:\dl\sandbox\18.0.23013.23795\mx\Applications.MX
Starting Business Central Service Tier
Importing license file
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 with AllowAppDatabaseWrite = False
Sync'ing Tenant
Tenant is Operational
Stopping Business Central Service Tier
Installation took 1256 seconds
Installation complete
Initializing...
Exception calling "Open" with "4" argument(s): "Access to the path 'c:\driversetc\hosts' is denied."
at UpdateHostsFile, C:\Run\my\updatehosts.ps1: line 20
at <ScriptBlock>, C:\Run\my\updatehosts.ps1: line 116
at <ScriptBlock>, C:\Run\my\SetupVariables.ps1: line 5
at <ScriptBlock>, C:\Run\navstart.ps1: line 24
at <ScriptBlock>, C:\Run\start.ps1: line 363
at <ScriptBlock>, <No file>: line 1Error
Adding ERROTRUSTCONTAI to hosts file
Using artifactUrl https://bcartifacts.azureedge.net/sandbox/18.0.23013.23795/mx
Using installer from C:\Run\150-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
start...
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
start...
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
start...
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
start...
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
start...
Starting Internet Information Server
Copying Service Tier Files
c:\dl\sandbox\18.0.23013.23795\platform\ServiceTier\Program Files
c:\dl\sandbox\18.0.23013.23795\platform\ServiceTier\System64Folder
Copying PowerShell Scripts
c:\dl\sandbox\18.0.23013.23795\platform\WindowsPowerShellScripts\Cloud\NAVAdministration
c:\dl\sandbox\18.0.23013.23795\platform\WindowsPowerShellScripts\WebSearch
Copying dependencies
Copying ReportBuilder
Importing PowerShell Modules
Determining Database Collation from c:\dl\sandbox\18.0.23013.23795\mx\BusinessCentral-MX.bak
Changing Database Server Collation to Modern_Spanish_100_CS_AS
Restoring CRONUS Demo Database
Setting CompatibilityLevel for tenant on localhost\SQLEXPRESS
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'
Copying Web Client Files
c:\dl\sandbox\18.0.23013.23795\platform\WebClient\Microsoft Dynamics NAV
Copying Client Files
c:\dl\sandbox\18.0.23013.23795\platform\LegacyDlls\program files\Microsoft Dynamics NAV
c:\dl\sandbox\18.0.23013.23795\platform\LegacyDlls\program files\Microsoft Dynamics NAV
c:\dl\sandbox\18.0.23013.23795\platform\LegacyDlls\systemFolder
Copying ModernDev Files
c:\dl\sandbox\18.0.23013.23795\platform
c:\dl\sandbox\18.0.23013.23795\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\sandbox\18.0.23013.23795\platform\ConfigurationPackages
Copying Test Assemblies
C:\dl\sandbox\18.0.23013.23795\platform\Test Assemblies
Copying Extensions
C:\dl\sandbox\18.0.23013.23795\mx\Extensions
Copying Applications
C:\dl\sandbox\18.0.23013.23795\platform\Applications
Copying Applications.MX
C:\dl\sandbox\18.0.23013.23795\mx\Applications.MX
Starting Business Central Service Tier
Importing license file
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 with AllowAppDatabaseWrite = False
Sync'ing Tenant
Tenant is Operational
Stopping Business Central Service Tier
Installation took 1256 seconds
Installation complete
Initializing...
Exception calling "Open" with "4" argument(s): "Access to the path 'c:\driversetc\hosts' is denied."
at UpdateHostsFile, C:\Run\my\updatehosts.ps1: line 20
at <ScriptBlock>, C:\Run\my\updatehosts.ps1: line 116
at <ScriptBlock>, C:\Run\my\SetupVariables.ps1: line 5
at <ScriptBlock>, C:\Run\navstart.ps1: line 24
at <ScriptBlock>, C:\Run\start.ps1: line 363
at <ScriptBlock>, <No file>: line 1
Initialization of container ErroTrustContainer failed
En C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.11\ContainerHandling\Wait-NavContainerReady.ps1: 43 Carácter: 17
+ ...             throw "Initialization of container $containerName failed" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Initialization ...ontainer failed:String) [], RuntimeException
    + FullyQualifiedErrorId : Initialization of container ErroTrustContainer failed

Additional context

Thanks

Rafael

freddydk commented 3 years ago

Try running

Check-BcContainerHelperPermissions -Fix

and then retry

rarrese commented 3 years ago

I did run it: PS C:\WINDOWS\system32> Check-BcContainerHelperPermissions -Fix Running as administrator Checking permissions to C:\ProgramData\BcContainerHelper RARRESE\rarrese does NOT have Full Control to C:\ProgramData\BcContainerHelper and all subfolders Trying to add permissions Permissions successfully added Checking permissions to C:\WINDOWS\System32\drivers\etc\hosts RARRESE\rarrese does NOT have modify permissions to C:\WINDOWS\System32\drivers\etc\hosts Trying to add permissions Permissions successfully added Checking permissions to docker commands RARRESE\rarrese has the right permissions to run docker commands

but with the same result: Installation complete Initializing... Exception calling "Open" with "4" argument(s): "Access to the path 'c:\driversetc\hosts' is denied." at UpdateHostsFile, C:\Run\my\updatehosts.ps1: line 20 at , C:\Run\my\updatehosts.ps1: line 116 at , C:\Run\my\SetupVariables.ps1: line 5 at , C:\Run\navstart.ps1: line 24 at , C:\Run\start.ps1: line 363 at , : line 1 Initialization of container ErroTrustContainer failed En C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.11\ContainerHandling\Wait-NavContainerReady.ps1: 43 Carácter: 17

Where should I find the directory \driversetc\hosts?

Thanks

freddydk commented 3 years ago

That folder is inside the container mapped to the c:\windows\system32\drivers\etc on the host. It looks like you have a anti-virus software or like that prevents your system in updating hosts. You can remove the -updatehosts parameter from the call, then the command should work - but maybe you cannot connect to the web client using the hostname of the container. You can try

rarrese commented 3 years ago

Thanks, it works