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


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,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',


Popular posts from this blog

Solving Sonarqube :- Project was never analyzed. A regular analysis is required before a branch analysis

spark - pyspark reading from excel files