Running SQL Server in a Container

This post is mostly a reminder to future me on the command to start SQL Server in a docker container.

Download the SQL Server image.

docker pull mcr.microsoft.com/mssql/server

Start it with -

docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=A!VeryComplex123Password" -p 1433:1433 --name my_sql_server -h my_sql_server  mcr.microsoft.com/mssql/server

At this point, you should be able to connect to the SQL Server and create a database, tables, etc.

The password

The password is very important, it has to satisfy the SQL Server complexity rules. This is what I was messing up the first time I tried running SQL Server in a container, I was also detaching the console from the running container, so all the log messages were hidden.

If the password is not complex enough the server will fail to start with an error like -

2021-08-10 00:18:05.72 spid26s     ERROR: Unable to set system administrator password: Password validation failed. The password does not meet SQL Server password policy requirements because it is not complex enough. The password must be at least 8 characters long and contain characters from three of the following four sets: Uppercase letters, Lowercase letters, Base 10 digits, and Symbols..
2021-08-10 00:18:05.74 spid26s     An error occurred during server setup. See previous errors for more information.
2021-08-10 00:18:05.74 spid26s     SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.
comments powered by Disqus

Related