MS SQL Server Docker data location

13.1k Views Asked by At

I am using the mcr.microsoft.com/mssql/server:2019-latest container and want to mount its data directory so that data does not get lost if the server goes down.

Where inside is the data directory located? The documentation does not mention this at all.

2

There are 2 best solutions below

0
On BEST ANSWER

The files, for SQL Server on Linux, are by default located in /var/opt/mssql. Unsurprising the Data files are in the data directory, and the log files in the log directory.

This is also in the documentation Change the default data or log directory location:

The filelocation.defaultdatadir and filelocation.defaultlogdir settings change the location where the new database and log files are created. By default, this location is /var/opt/mssql/data.

4
On

Depends on the OS platform and if the persistent storage is mounted

If it is Linux, then it according to @Larnu answer.

For Windows, it is still C:\Program Files\Microsoft SQL Server...

However, in both cases the data will have a lifetime of the container. At the restart of the container all changes will be gone.

In case of mounted volumes, the location is to be determined by the volume and the data is persistent, so it can survive restart of the container