microsoft / navcontainerhelper

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

NavContainer and SQL Server on Host #307

Closed thenavguy closed 5 years ago

thenavguy commented 5 years ago

Hello,

We have SQL Server 2017 (Standard Edition) installed on the Azure VM(Windows Server 2012 + Domain Controller).

We are trying to install newNAVContainer with the database to be on SQL Server 2017 running on the host machine.

We are executing below script but getting error and docker fails. New-NavContainer -containerName bccu2 -accept_eula -accept_outdated -alwaysPull -assignPremiumPlan -auth Windows -clickonce -databaseCredential sa -databaseName bccu2 -databaseServer gms\MSSQLSERVER -doNotExportObjectsToText -enableSymbolLoading -imageName mcr.microsoft.com/businesscentral/onprem:cu2-na -includeCSide -includeTestLibrariesOnly -myScripts c:\myfolder ` -restart on-failure -shortcuts Desktop -updateHosts -useBestContainerOS

After few minutes of processing, docker ends and display's the below error Starting Internet Information Server Import Encryption Key Cannot establish a connection to the SQL Server/Database.

This could be due to one of the following reasons:

Try again later or contact your system administrator. at , C:\Run\SetupDatabase.ps1: line 122 at , C:\Run\navstart.ps1: line 108 at , C:\Run\start.ps1: line 121 at , : line 1 Initialization of container bccu2 failed At C:\Program Files\WindowsPowerShell\Modules\navcontainerhelper\0.4.2.6\ContainerHandling\Wait-NavContainerReady.ps1:45 char:17

Since I am not an Infra guy, requesting you all to please provide with your suggestion what is wrong in the powershell command or any link, which we can follow.

Regards, TNG

freddydk commented 5 years ago

You write Windows Server 2012 - I didn't think you can run docker on that, so I assume that is a typo or something i misunderstood.

This is likely because the container cannot see the host when using the servername gms alone. You might need to use a fully qualified name or the ip address or you might need to run the container using transparent networking (the container will act as if is a machine on your network).

tommyb1987 commented 5 years ago

I have something simuler When i try to create a new Navcontainer using the script below it all works.

New-NavContainer -containerName NAV2016-cu1-be -accept_eula -accept_outdated -assignPremiumPlan -auth Windows -clickonce -doNotExportObjectsToText -enableSymbolLoading -imageName microsoft/dynamics-nav:2016-cu1-be -includeCSide -includeTestLibrariesOnly -includeTestToolkit -multitenant -navDvdCountry BE

BUT: If I use the same script with my local SQL and add the parameters -databaseCredential sa -databaseInstance Docker -databaseName TestContainer -databaseServer Test-Laptop The Database instance is running on an SQL 2016 version. The Database is a database that exissets on the SQL instance but even if the database does not exisist the error is the same.

Error: Import Encryption Key Cannot establish a connection to the SQL Server/Database. This could be due to one of the following reasons: The SQL server is not started. The database does not exist. Proper permissions have not been given to the NAV Server Account. Try again later or contact your system administrator. at , C:\Run\SetupDatabase.ps1: line 122 at , C:\Run\navstart.ps1: line 108 at , C:\Run\start.ps1: line 121 at , : line 1 Initialization of container NAV2016-cu1-be failed At C:\Program Files\WindowsPowerShell\Modules\navcontainerhelper\0.5.0.2\ContainerHandling\Wait-NavContainerReady.ps1:45 char:17 ... throw "Initialization of container $containerName failed" ...


CategoryInfo : OperationStopped: (Initialization ...6-cu1-be failed:String) [], RuntimeException
FullyQualifiedErrorId : Initialization of container NAV2016-cu1-be failed

The SQL server is not started. --> **is started + the SQL Browser is up**
The database does not exist. --> **Database is present**
Proper permissions have not been given to the NAV Server Account. --> **SA user so the SQL server should be aprochable.**
thenavguy commented 5 years ago

Hi tommyb1987,

I too unable to run container with local sql server.

My environment details Windows Server 2016 Version 1607 (OS Build 14393.2828)

SQL Server 2016 installed, used sa credentials with new-navcontainer cmdlet. Tried both connecting existing NAV database for this container as well without specifying any database name.

Could not find comprehensive info on web for having new-navcontainer with local SQL.

If you are able to do that, please share how you managed to that.

Thanks

freddydk commented 5 years ago

typically a container cannot see the host when using NAT. You might need to run transparent network to make that work. On my windows 10 1809 with NAT networking, the container can ping the IP address of the host, but not ping the name. You could try to use the IP number to see whether that is the issue.

thenavguy commented 5 years ago

Thanks @freddydk for your prompt reply.

I am bit rookie in Docker and the environment is on Azure VM. Can you please provide some link or reference which I can use to try this.

It's the only hindrance we have for using Docker in our company. Thanks & regards.

freddydk commented 5 years ago

Unfortunately this is one of the things people have problems with, but this thread gave me an idea, which I want to try out - will be back with more later (or tomorrow)

tommyb1987 commented 5 years ago

I'm now trying to open a network conenction using the ollowing Powershell script. $accept_eula = $true

$containername = 'TestNet' $navdockerimage = 'mcr.microsoft.com/businesscentral/sandbox:14.0.29537.0-be' $appbacpacuri = '' $tenantbacpacuri = '' $additionalParameters = @("--network tlan") if ($appbacpacuri -ne '' -and $tenantbacpacuri -ne '') { $additionalParameters = @("--env appbacpac=""$appbacpacuri""","--env tenantBacpac=""$tenantbacpacuri""") } $credential = get-credential -UserName $env:USERNAME -Message "Using Windows Authentication. Please enter your Windows credentials." New-NavContainer -accept_eula:$accept_eula -containername $containername -auth Windows -Credential $credential -includeCSide -alwaysPull -doNotExportObjectsToText -usessl:$false -updateHosts -assignPremiumPlan -shortcuts Desktop -imageName $navdockerimage -additionalParameters $additionalParameters Setup-NavContainerTestUsers -containerName $containername -password $credential.Password

However i'm getting an error Invoke GET on http://:7048/NAV/api/beta/companies?$filter=name%20eq%20%27CRONUS%20BE%27&tenant=default Invoke-NavContainerApi : Cannot bind parameter 'Uri'. Cannot convert value "http://:7048/NAV/api/beta/companies?$filter=name%20eq%20%27CRONUS%20BE%27&tenant=default " to type "System.Uri". Error: "Ongeldige URI: de hostnaam kan niet worden geparseerd." At C:\Users\tommyb\Documents\WindowsPowerShell\Modules\navcontainerhelper\0.5.0.11\Api\Get-NavContainerApiCompanyId.ps1:60 char:15

Please help.

freddydk commented 5 years ago

Could you copy/paste a docker inspect of that container? Your network seems to not get an IP address - or I cannot find it... This makes Setup-NavContainerTestUsers fail.

tommyb1987 commented 5 years ago

C:\Users\tommyb>docker inspect --type=container TestNet [ { "Id": "bcbb5602cc22a5b5da1775d00ceed228869e6f1a871fd6ff2e76dc4834f8bd0c", "Created": "2019-04-05T12:12:44.2377826Z", "Path": "powershell", "Args": [ "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';", ".\Run\start.ps1" ], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 1944, "ExitCode": 0, "Error": "", "StartedAt": "2019-04-05T12:13:00.5453089Z", "FinishedAt": "0001-01-01T00:00:00Z", "Health": { "Status": "healthy", "FailingStreak": 0, "Log": [ { "Start": "2019-04-05T14:43:53.5365751+02:00", "End": "2019-04-05T14:43:53.937797+02:00", "ExitCode": 0, "Output": "" }, { "Start": "2019-04-05T14:44:23.9481026+02:00", "End": "2019-04-05T14:44:24.3746917+02:00", "ExitCode": 0, "Output": "" }, { "Start": "2019-04-05T14:44:54.385847+02:00", "End": "2019-04-05T14:44:54.8554423+02:00", "ExitCode": 0, "Output": "" }, { "Start": "2019-04-05T14:45:24.8781895+02:00", "End": "2019-04-05T14:45:25.2596234+02:00", "ExitCode": 0, "Output": "" }, { "Start": "2019-04-05T14:45:55.2843486+02:00", "End": "2019-04-05T14:45:55.7236207+02:00", "ExitCode": 0, "Output": "" } ] } }, "Image": "sha256:b031a840e349d7dca42e42757ab553388f1aef45ea740c71a36756a7af90da1f", "ResolvConfPath": "", "HostnamePath": "", "HostsPath": "", "LogPath": "C:\ProgramData\Docker\containers\bcbb5602cc22a5b5da1775d00ceed228869e6f1a871fd6ff2e76dc4834f8bd0c\bcbb5602cc22a5b5da1775d00ceed228869e6f1a871fd6ff2e76dc4834f8bd0c-json.log", "Name": "/TestNet", "RestartCount": 0, "Driver": "windowsfilter", "Platform": "windows", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "", "ExecIDs": null, "HostConfig": { "Binds": [ "C:\ProgramData\NavContainerHelper:C:\ProgramData\NavContainerHelper", "C:\ProgramData\NavContainerHelper\Extensions\TestNet\my:C:\Run\my", "C:\ProgramData\NavContainerHelper\Extensions\TestNet\Program Files:C:\navpfiles", "c:\windows\system32\drivers\etc:C:\driversetc" ], "ContainerIDFile": "", "LogConfig": { "Type": "json-file", "Config": {} }, "NetworkMode": "default", "PortBindings": {}, "RestartPolicy": { "Name": "unless-stopped", "MaximumRetryCount": 0 }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "CapAdd": null, "CapDrop": null, "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "GroupAdd": null, "IpcMode": "", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 0, "ConsoleSize": [ 0, 0 ], "Isolation": "hyperv", "CpuShares": 0, "Memory": 4294967296, "NanoCpus": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": [], "BlkioDeviceReadBps": null, "BlkioDeviceWriteBps": null, "BlkioDeviceReadIOps": null, "BlkioDeviceWriteIOps": null, "CpuPeriod": 0, "CpuQuota": 0, "CpuRealtimePeriod": 0, "CpuRealtimeRuntime": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": [], "DeviceCgroupRules": null, "DiskQuota": 0, "KernelMemory": 0, "MemoryReservation": 0, "MemorySwap": 0, "MemorySwappiness": null, "OomKillDisable": false, "PidsLimit": 0, "Ulimits": null, "CpuCount": 0, "CpuPercent": 0, "IOMaximumIOps": 0, "IOMaximumBandwidth": 0, "MaskedPaths": null, "ReadonlyPaths": null }, "GraphDriver": { "Data": { "dir": "C:\ProgramData\Docker\windowsfilter\bcbb5602cc22a5b5da1775d00ceed228869e6f1a871fd6ff2e76dc4834f8bd0c" }, "Name": "windowsfilter" }, "Mounts": [ { "Type": "bind", "Source": "c:\programdata\navcontainerhelper\extensions\testnet\program files", "Destination": "c:\navpfiles", "Mode": "", "RW": true, "Propagation": "" }, { "Type": "bind", "Source": "c:\windows\system32\drivers\etc", "Destination": "c:\driversetc", "Mode": "", "RW": true, "Propagation": "" }, { "Type": "bind", "Source": "c:\programdata\navcontainerhelper", "Destination": "c:\programdata\navcontainerhelper", "Mode": "", "RW": true, "Propagation": "" }, { "Type": "bind", "Source": "c:\programdata\navcontainerhelper\extensions\testnet\my", "Destination": "c:\run\my", "Mode": "", "RW": true, "Propagation": "" } ], "Config": { "Hostname": "TestNet", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "ExposedPorts": { "1433/tcp": {}, "443/tcp": {}, "7045/tcp": {}, "7046/tcp": {}, "7047/tcp": {}, "7048/tcp": {}, "7049/tcp": {}, "80/tcp": {}, "8080/tcp": {} }, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "accept_eula=Y", "auth=Windows", "username=tommyb", "locale=nl-BE", "licenseFile=", "databaseServer=", "enableApiServices=Y", "passwordKeyFile=c:\run\my\aes.key", "ExitOnError=N", "databaseInstance=", "useSSL=N", "securePassword=76492d1116743f0423413b16050a5345MgB8AGsAQQBlAHgAZwBOAGIAUQBvAFYARQBlAEoAQQBxAHkAMgBYADYAeQBrAEEAPQA9AHwAYwBkADcANwAzADIAZQA4AGIANQAxAGUAZQBlADgAOQAzAGQAYwA3ADQANgBiAGYAZAA2ADcAYgA1ADMANwBiADgAYgBjAGEAMQA5ADAAZgBmAGEAYgBkADkAMwA4AGIAMQAwADkAMwAwADYANABhAGIAYgBiADkANABlADAAZQA=", "removePasswordKeyFile=Y", "COMPLUS_NGenProtectedProcess_FeatureEnabled=0", "DatabaseName=FinancialsBE", "NAVDVDURL=https://nav2016wswe0.blob.core.windows.net/dvd/0c23868b-edd4-4324-b8bf-f26eebe21bf6", "VSIXURL=https://nav2016wswe0.blob.core.windows.net/dvd/al-3.0.106655.vsix", "IsBcSandbox=Y", "CountryCode=BE", "DEVPREVIEWURL=https://nav2016wswe0.blob.core.windows.net/dvd/d61364d3-fc25-4a71-9331-394709bd1b37" ], "Cmd": [ "powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';", ".\Run\start.ps1" ], "Healthcheck": { "Test": [ "CMD", "powershell", ".\Run\HealthCheck.ps1" ], "Interval": 30000000000, "Timeout": 10000000000 }, "ArgsEscaped": true, "Image": "mcr.microsoft.com/businesscentral/sandbox:14.0.29537.0-be-ltsc2016", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": { "country": "BE", "created": "201904030416", "cu": "", "eula": "https://go.microsoft.com/fwlink/?linkid=861843", "legal": "http://go.microsoft.com/fwlink/?LinkId=837447", "maintainer": "Dynamics SMB", "nav": "", "osversion": "10.0.14393.2848", "platform": "14.0.29530.0", "tag": "0.0.9.3", "version": "14.0.29537.0" } }, "NetworkSettings": { "Bridge": "", "SandboxID": "bcbb5602cc22a5b5da1775d00ceed228869e6f1a871fd6ff2e76dc4834f8bd0c", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": { "1433/tcp": null, "443/tcp": null, "7045/tcp": null, "7046/tcp": null, "7047/tcp": null, "7048/tcp": null, "7049/tcp": null, "80/tcp": null, "8080/tcp": null }, "SandboxKey": "bcbb5602cc22a5b5da1775d00ceed228869e6f1a871fd6ff2e76dc4834f8bd0c", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "", "Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "", "IPPrefixLen": 0, "IPv6Gateway": "", "MacAddress": "", "Networks": { "nat": { "IPAMConfig": null, "Links": null, "Aliases": null, "NetworkID": "548f5602ada086ee8270e80cb1e3d4b5e3f06ac2c4a60e9e20b92dc2fe9e0fe6", "EndpointID": "ea423d939706585ce4aae2fba41e9add3844b23ba3fed784e922a5b29cb2fc3f", "Gateway": "172.21.160.1", "IPAddress": "172.21.167.59", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "00:15:5d:ac:b6:8b", "DriverOpts": null }, "tlan": { "IPAMConfig": {}, "Links": null, "Aliases": [ "bcbb5602cc22" ], "NetworkID": "fd7107d6e4030a25857ef8563591c45ef9be950d14d8242b423abef4c6174e44", "EndpointID": "ac6142ed54c8fb52c27bebfc8d2379160ff9a0b09b726b8adf301c5be16fc27d", "Gateway": "", "IPAddress": "", "IPPrefixLen": 0, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "00:15:5d:ae:49:3b", "DriverOpts": null } } } } ]

freddydk commented 5 years ago

I don't think your tlan is configured properly (no IP address in that) - and it seems like you have two networks on that container. I haven't worked with tlan myself, I guess you are trying to run the container so that it can connect to the SQL Server on your host. What are you trying to achieve? why can't you use the SQL server in the container?

tommyb1987 commented 5 years ago

I'm traying to have a local database connected tot the docker evirement. The reason for this is that i need to do a migration of Data as a test for one of our clients. We want to use docker so we can easely install and uninstall the newer versions and test our own extentions on it. The current database is about 40 gig large and sinds the standard docker container only comes with a SQL expres we can not use that one.

Inspection of the tlan network

[ { "Name": "tlan", "Id": "3429149d72807b3377027f83460de19cfec260feeb52d32dc089a97bff8d45b4", "Created": "2019-04-08T08:18:50.783478+02:00", "Scope": "local", "Driver": "transparent", "EnableIPv6": false, "IPAM": { "Driver": "windows", "Options": null, "Config": [ { "Subnet": "0.0.0.0/0" } ] }, "Internal": false, "Attachable": false, "Ingress": false, "ConfigFrom": { "Network": "" }, "ConfigOnly": false, "Containers": {}, "Options": { "com.docker.network.windowsshim.hnsid": "2fe62f4b-d2e9-4196-88ea-570d66cd4e8c", "com.docker.network.windowsshim.networkname": "tlan" }, "Labels": {} } ]

freddydk commented 5 years ago

Did you ever manage to make this work?