简体   繁体   中英

Docker container running SQL Server exits on start

I'm running an instance of SQL Server in a Docker container. It exits on start automatically. The logs say:

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

If I am reading this right SQL Server will not run with root user. But then both my container and volume are running as the same non-root user. So I'm confused where the problem is coming from. Can someone help me decode this error message?

This error can be caused by binding the sql server volume /var/opt/mssql in the wrong way.

Eg

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

Instead, ensure to map subvolumes of /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

A bit more detail on the problem https://www.herlitz.io/2022/12/22/sql-server-in-docker---palinstanceid-unable-to-read-instance-id-from-file/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM