TLDR;
It seems the documentation on how to start the Linux based sql server container contains a bug!
The documentation states you need to start the container using the following command-line:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
But this is wrong because it will not set the password for SA
It took me hours to discover the environment variable actually used to set the SA password is 'MSSQL_SA_PASSWORD'
So when you use the following command line it just works
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
Steps to reproduce:
- Run the command-line as advertised in the documentation to start the container.
- Run a docker exec command to run a bash shell in the container interactively
- Run the following command:
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'yourStrong(!)Password'
This will give you the following error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user 'SA'..
Now remove the container and try again, but replace the -e 'SA_PASSWORD=yourStrong(!)Password' with -e 'MSSQL_SA_PASSWORD=yourStrong(!)Password'
Try the same steps again, and voila, you are connected to the SQL server.
TLDR;
It seems the documentation on how to start the Linux based sql server container contains a bug!
The documentation states you need to start the container using the following command-line:
But this is wrong because it will not set the password for SA
It took me hours to discover the environment variable actually used to set the SA password is 'MSSQL_SA_PASSWORD'
So when you use the following command line it just works
Steps to reproduce:
This will give you the following error:
Now remove the container and try again, but replace the -e 'SA_PASSWORD=yourStrong(!)Password' with -e 'MSSQL_SA_PASSWORD=yourStrong(!)Password'
Try the same steps again, and voila, you are connected to the SQL server.