mssql docker windows container
The best way to setup docker for mssql server (developer edition) is using the following image and it can be as simple as this. Please note that this image supports database mounting (it comes for free).
FROM microsoft/mssql-server-windows-developer
ENV SA_PASSWORD=Password1!
ENV ACCEPT_EULA=Y
To build it.
docker build -t mssql:v1 .
To mount database with your local directory, just run the following command :-
docker run -d -p 1400:1433 -v C:/mssqldata/:C:/mssqldata/ -e attach_dbs="[{'dbName': 'PTS','dbFiles': ['C:\\mssqldata\\pts.mdf','C:\\mssqldata\\pts_log.ldf']}]" mssql:v1
Noticed i am mounting my local folder called c:\mssqldata and specify environment settings called attach_dbs and it is in json format.
After running it, fire up your, connect to your localhost 127.0.0.1,1400 port and you will see your mounted database.
If you have multiple database, it can be in this format :-
[
{
'dbName': 'PTS',
'dbFiles': ['C:\\mssqldata\\pts.mdf','C:\\mssqldata\\pts_log.ldf']
},
{
'dbName': 'PerryDb',
'dbFiles': ['C:\\temp\\perrytest.mdf',
'C:\\temp\\perrytest_log.ldf']
}
]
Comments