skip to Main Content

I’m trying to connect to a SQL Server Docker container via SQL Server Management Studio, but it doesn’t work. When I attempt to connect, I get this error:

Login failed for user ‘sa’. (Microsoft SQL Server, Error: 18456)

I run the container with this command:

docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=yourStrong(!)Password" 
           -p 1433:1433 --name=bd_sql_server 
           -d mcr.microsoft.com/mssql/server:2022-latest

Here is the info I provided in the "Connect to server" window in SSMS:

"Connect to server" window in SSMS

and the container running in Docker Desktop:

Container running in Docker Desktop

I made sure that the password was the same I specified.

I can’t seem to find what I’m doing wrong. Can you help me?

Thanks.

2

Answers


  1. @MathisMahaux

    hi Mathis, Charlie here

    probably you have a windows desktop version of MSSQL and you forgot to stop the local service before connecting to the docker version.

    good Luck !

    Login or Signup to reply.
  2. Test that the SQL server is assecible within container

    docker exec -it bd_sql_server /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P yourStrong(!)Password
    

    if you can connect to the SQL command line , than there is the problem with the MSSQL configuration and network setting

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search