mssql-docker icon indicating copy to clipboard operation
mssql-docker copied to clipboard

Need to document best practices - security, data persistence, etc.

Open twright-msft opened this issue 9 years ago • 5 comments

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.

twright-msft avatar Jan 09 '17 22:01 twright-msft

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.

barspi avatar Apr 26 '17 02:04 barspi

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

twright-msft avatar Apr 26 '17 04:04 twright-msft

Best practices are documented here: https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-docker

twright-msft avatar Jun 20 '17 04:06 twright-msft

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.

riker09 avatar Aug 03 '17 09:08 riker09

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:

  1. 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
  2. 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

perrysk-msft avatar Aug 03 '17 18:08 perrysk-msft