How to Fix: Login failed for SA when running MS SQL Server on Linux in a Docker container
By: Date: 5 October 2020 Categories: Geen categorie

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 they actually use to set the SA password is ‘MSSQL_SA_PASSWORD’

So when you use the following command line it just works

Hopefully it will save you from pulling your hear out and also searching for hours. I filed this as a bug, hopefully the docs or the scripts are updated soon. Github Issue

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:

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.

Leave a Reply

Your email address will not be published. Required fields are marked *