Reputation: 303
I have issues connecting with MSSQL Server Management Studio to my running docker container.
A beginner in docker.
I have created a following docker-compose.yml
file:
version: '3.4'
services:
sqlserver:
image: "mcr.microsoft.com/mssql/server:2017-latest"
volumes:
- /var/lib/docker/volumes/sql_volume/_data
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: "pa55w0rd!"
MSSQL_PID: "Express"
ports:
- "1533:1534"
adventureworks_service:
image: ${DOCKER_REGISTRY-}adventureworksservice
build:
context: .
dockerfile: AdventureWorks_Service/Dockerfile
this docker file should start a MSSQL Database and the adventureworks_service project located in my solution.
this docker-compose is located in it's own Docker project, in the solution. created with the "add docker support" for my Web API project
assuming everything is correctly setup, I should be able to connect to the sql server on localhost:1533
, using SQL server authentication with login Express
and password pa55w0rd!
.
I get following error right after attempting to connect (no timeouts, etc.)
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider : TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host) (Microsoft SQL Server, Error: 10054)
Does anyone know how I can access this server / container?
Thanks in advance
Upvotes: 1
Views: 2916
Reputation: 1
If you still have this error in your SSMS, make sure that you are using correct host name with port it should be localhost,1433 with comma
Upvotes: 0
Reputation: 431
The port in mssql should be 1433
rather than 1534
, try this
version: '3.4'
services:
sqlserver:
image: "mcr.microsoft.com/mssql/server:2017-latest"
volumes:
- /var/lib/docker/volumes/sql_volume/_data
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: "pa55w0rd!"
MSSQL_PID: "Express"
ports:
- "1433:1433" # the port behind should always be 1433
adventureworks_service:
image: ${DOCKER_REGISTRY-}adventureworksservice
build:
context: .
dockerfile: AdventureWorks_Service/Dockerfile
then your connection string should be like this
Data Source=sqlserver,1433;User Id=SA;Password=pa55w0rd!
Upvotes: 1
Reputation: 2972
Try adding network_mode: "host"
to your compose file.
version: '3.4'
services:
sqlserver:
image: "mcr.microsoft.com/mssql/server:2017-latest"
volumes:
- /var/lib/docker/volumes/sql_volume/_data
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: "pa55w0rd!"
MSSQL_PID: "Express"
ports:
- "1533:1534"
network_mode: "host"
adventureworks_service:
image: ${DOCKER_REGISTRY-}adventureworksservice
build:
context: .
dockerfile: AdventureWorks_Service/Dockerfile
Upvotes: 0