MS SQL 服务器 Docker 数据位置

MS SQL Server Docker data location

我正在使用 mcr.microsoft.com/mssql/server:2019-latest 容器并想挂载其数据目录,以便在服务器出现故障时数据不会丢失。

数据目录在里面的什么地方?文档根本没有提到这一点。

Linux 上 SQL 服务器的文件默认位于 /var/opt/mssql。不出所料,数据文件位于 data 目录中,日志文件位于 log 目录中。

这也在文档中 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.

取决于OS平台以及是否安装了持久存储

如果是Linux,则按照@Larnu的回答。

对于Windows,还是C:\Program Files\Microsoft SQL Server...

但是,在这两种情况下,数据都将具有容器的生命周期。在容器重新启动时,所有更改都将消失。

在挂载卷的情况下,位置由卷确定并且数据是持久的,因此它可以在容器重启后继续存在