运行SQL Server的Docker容器在启动时退出

xxe27gdn  于 2022-12-26  发布在  SQL Server
关注(0)|答案(1)|浏览(504)

我正在Docker容器中运行SQL Server示例。它在启动时自动退出。日志显示:

SQL Server 2019 will run as non-root by default.
This container is running as user mssql.
Your master database file is owned by mssql.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
sqlservr: Unable to read instance id from /var/opt/mssql/.system/instance_id: File: pal.cpp:438 [Status: 0xC0000034 Object name not found errno = 0x2(2) No such file or directory]
/opt/mssql/bin/sqlservr: PAL initialization failed. Error: 101

如果我没阅读的话,SQL Server不会以root用户身份运行。但是我的容器和卷都是以同一个非root用户身份运行的。所以我很困惑问题是从哪里来的。有人能帮我解码这个错误消息吗?

laawzig2

laawzig21#

此错误可能是由于以错误的方式绑定sql server卷/var/opt/mssql造成的。
例如

docker run `
    --name sqlexpress `
    -e ACCEPT_EULA=Y `
    -e MSSQL_SA_PASSWORD="averyuRandomPass0wrd" `
    -p 1433:1433 `
    -v "/var/lib/docker/mssql:/var/opt/mssql" `
    -e MSSQL_PID="Express" `
    -d mcr.microsoft.com/mssql/server:latest

相反,请确保Map/var/opt/mssql的子卷

docker run `
    --name sqlexpress `
    -e ACCEPT_EULA=Y `
    -e MSSQL_SA_PASSWORD="averyuRandomPass0wrd" `
    -p 1433:1433 `
    -v "/var/lib/docker/mssql/data:/var/opt/mssql/data" `
    -v "/var/lib/docker/mssql/log:/var/opt/mssql/log" `
    -e MSSQL_PID="Express" `
    -d mcr.microsoft.com/mssql/server:latest

关于问题https://www.herlitz.io/2022/12/22/sql-server-in-docker---palinstanceid-unable-to-read-instance-id-from-file/的更多细节

相关问题