6

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.

Werner Raath
  • 1,322
  • 3
  • 16
  • 34

2 Answers2

10

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.

Thom A
  • 88,727
  • 11
  • 45
  • 75
2

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

Alexander Volok
  • 5,630
  • 3
  • 17
  • 33
  • SQL Server Docker Images are Linux based, not Windows. By Default the Docker instance is also Ubuntu Based, however, there are RHEL images available too. – Thom A Oct 15 '20 at 12:56
  • @Larnu, There are also Windows based images available since recently. For instance, https://hub.docker.com/r/microsoft/mssql-server-windows-developer/ – Alexander Volok Oct 15 '20 at 12:57
  • 2
    True, but the OP did link to the link based one: https://hub.docker.com/_/microsoft-mssql-server – Thom A Oct 15 '20 at 13:02
  • I see, thanks, it is clear now that the platform is Linux. – Alexander Volok Oct 15 '20 at 13:04