Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker - MSSQL_COLLATION not set

I'm trying to create a container with SQL Server running on with this command:

docker run -e "ACCEPT_EULA=Y" -e MSSQL_SA_PASSWORD="MyPassword1" 
           -e MSSQL_COLLATION="Polish_CI_AS" -p 1434:1433 
           -v C:/Users/User1/sql-server/data:/var/opt/mssql/data 
           -d mcr.microsoft.com/mssql/server:2019-latest 

Everything is working fine, the env variable is set but the server collation is still the default - SQL_Latin1_General_CP1_CI_AS.

Any ideas?

like image 852
MaciekB Avatar asked Nov 17 '25 04:11

MaciekB


1 Answers

Note that at the time of this writing, MSSQL_COLLATION only works when initializing the server for the first time (i.e. creating the master database). In order to change the server collation:

  1. Create backups of all user databases.
  2. Stop the old container.
  3. Start container with -e MSSQL_COLLATION=Polish_CI_AS. Ensure the data volume is empty except for the backups.
  4. Restore from the backups.
like image 77
Dyllon Gagnier Avatar answered Nov 18 '25 19:11

Dyllon Gagnier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!