Need to document best practices - security, data persistence, etc.
Examples of things that should be documented as best practices:
-
Change the sa account password after docker run so that the actual password is not stored in the SA_PASSWORD env variable.
-
Use persistent storage for db data/log files and config ini file.
-
Use container volume for data persistence on macOS for now since mapped host volumes don't work.
this may be related, but I wanted to change the password using /opt/mssql/bin/mssql-conf/set-sa-passwordand couldn't do it for a variety of reasons, including that the scripts call sudo which is not installed in the image (and after installing it, I think it tries to change to a mssql user or something... it was like 4am and can't remember right now :-) )
I think it should be possible to re-run the sql server setup and change whatever parameters, without instantiating a new container.
Once SQL Server is up and running you can change the sa password via T-SQL using ALTER LOGIN. https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-login-transact-sql
However, there is an important scenario that we need to cover which is recovering when the SA login's password has been forgotten. I've added that to the issues backlog. https://github.com/Microsoft/mssql-docker/issues/77
Best practices are documented here: https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-docker
Are there any documented best practices for windows? I'm trying to figure out how to persist data of a container running the mssql-server-windows-express image. I cannot use a volume mount to C:/Program Files/Microsoft SQL Server/MSSQL13.SQLEXPRESS/MSSQL/DATA since that file already contains the (empty) default database. Mounting a host folder or named volume to container folder, that already contains files will not work under windows with a windows container. Or something like that. I believe I read that somewhere.
Thanks @riker09! Could you please post the error that you are getting when you are mapping the MSSQL/DATA folder? It seems to work on my end. Alternatively, you could map another folder (E.g. C:\temp) and then create all the dbs in that folder instead of the default sql location:
- docker run -d -p 1433:1433 -e sa_password=<YOUR_COMPLEX_PASSWORD> -e ACCEPT_EULA=Y -v C:\temp:C:\temp\ microsoft/mssql-server-windows-express
- docker exec -it
sqlcmd
CREATE DATABASE sampledb ON (NAME = sampledb_dat, FILENAME = 'C:\temp\sampledb.mdf') LOG ON (NAME = sampledb_log, FILENAME = 'C:\temp\sampledb.ldf') go