Is it possible to connect to SQL Server Express (localdb) from a container instance?
docker-compose sample connection string:
foo-api:
image: foo-api
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ConnectionStrings:DefaultConnection=Server=host.docker.internal\\mssqllocaldb;Database=FooDB;MultipleActiveResultSets=true;User Id=foo;Password=Your_password123;
build:
context: ../ms-foo/src/
dockerfile: Dockerfile
ports:
- "6004:6004"
Running the app @ localhost wtih this config works just fine:
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=FooDB;MultipleActiveResultSets=true;User Id=foo;Password=Your_password123;"
},
Is there some dns resolution I'm missing or does the instance need to be shared somehow?
Update
Including the error message.
{ "error": "14 UNAVAILABLE: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 25 - Connection string is not valid)"}
foo-api
? do you get a timeout?