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

[QUESTION] Problem connecting to an SQL Express database on the docker host #3671

Open ChrisChristophers opened 3 weeks ago

ChrisChristophers commented 3 weeks ago

Hi

I am having issues to setup BC with an SQL Express DB on the docker host. I am using following script:

New-BCContainer `
    -accept_eula `
    -containerName $containerName `
    -multitenant:$multitenant `
    -updateHosts `
    -artifactUrl $20ArtifactUrl `
    -memoryLimit 10G `
    -EnableTaskScheduler:$false `
    -licenseFile $partnerLicense `
    -auth NavUserPassword `
    -Credential $databaseCredential `
    -databaseServer '172.31.64.1' `
    -databaseInstance 'SQLEXPRESS' `
    -databaseName $databaseName `
    -databaseCredential $databaseCredential `
    -accept_outdated `
    -shortcuts None `
    -alwaysPull `  

This is the Host & SQL Info:

image

image

image

This is the Error Msg.

image

Help would be appreciated.

KristofKlein commented 3 weeks ago

I would start with: can you ping the host from within the container on that IP? else with bccontainerhelper you get a dns entry within the container that you can use : host.containerhelper.internal try to use that instead.

Furthermore you can check in the logs of the SQL server if the container service is even reaching the DB ? if the container reached a running state you might also connect into it and make use of invoke-sqlcmd to try out the accessibility with that.

ChrisChristophers commented 3 weeks ago

If i start a cronus container , i can ping the host. I also tried setting -databaseServer 'host.containerhelper.internal' ` , unfortunately to no avail. Maybe for whatever reason the service has trouble connecting to the SQLEXPRESS instance?

Also , i have a database on another machine ( not the host ) to which i can connect without any issues. The difference is that it's a regular SQL Server without a instance name so i can omit it.

KristofKlein commented 3 weeks ago

well, if it is a service issue: event log or try to play with invoke-sqlcmd and see if you can connect to the DB at all and maybe get some more meaningful error from it .

left-code commented 3 weeks ago

I would try to set -databaseServer '172.31.64.1\SQLEXPRESS' and omit instance name as parameter.

freddydk commented 1 week ago

Did you manually restore your database to the database server on the host? Does the database with $databaseName already exist?

If you want BcContainerHelper to generate the database for you, you need to specify -replaceExternalDatabases !