8

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?

2
  • I have to little info, missing docker file, missing docker run command. Check out this repo with lot's of examples running sql server in docker: github.com/enriquecatala/mssql-server-samplesdb Commented Aug 23, 2022 at 9:51
  • In prior versions of SQL Server for Docker the SQL Server process did run as root, but since about 2019 they now abide by the Least Privilege principle and run with a specific mssql user. Given the "No such file or directory" error message, have you changed the Docker volumes/mounts on the container recently? Commented Aug 23, 2022 at 10:01

5 Answers 5

8

I have got same this error and I resolved it by way remove the file /var/opt/mssql/.system/instance_id and then restart service again

Sign up to request clarification or add additional context in comments.

Comments

7

UPD 2025:

I once again had this issue, and its due to 0 free space on disk. In this case you delete or update instance_id but after container start the issue will repeat itself and instnce_id file will remain empty, and SQL wont start ☝️

2023:

I had this exact issue today. It happened after I resized disk partition somehow.

At first I inspected docker volume and data seemed to be ok, however

/var/opt/mssql/.system/instance_id

wich is

/var/lib/docker/volumes/[YOUR-VOLUME]/_data/.system/instance_id

was empty!

Then I googled this thread https://github.com/microsoft/mssql-docker/issues/615 suggested to run chown 10001:0 on _data folder wich did not help.

Fortunately my docker is running inside Hyper-V vm. So I created checkpoint and reverted to previous one to see whats inside instance_id file

It turned out to be guid and 20 digit number

dfb10ba0-dc20-4022-ab31-0f52be4dcabe
16537894658124376490

I copied that and returned to latest checkpoint. Stopped container, updated instance_id with recovered data and container started seamlessly.

SQL Server on Linux stores the sequential UUID seed in /var/opt/mssql/.system/instance_id and increments it during startup. Take a backup of the instance_id file in case of system failure. If the file is lost, the seed is missing, and the new seed is regenerated. The initial seed generation is based on a random bit pattern and a UUID to avoid collisions. However, the new seed that has to be sequentially ordered may not be sequentially ordered after the seed is lost.

https://support.microsoft.com/en-us/topic/kb4078097-fix-newsequentialid-function-generates-duplicate-guid-after-sql-server-2017-on-linux-is-restarted-829b97f7-6359-8f66-6581-37aac819c210

1 Comment

Same I had no space left in device
4

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

E.g.

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/

Comments

1

I had the same issue after I resized disk partition. instance_id file was empty! I had full back up of db data. So, I took chance and created random UUID and copied to the file . it worked !

Generated UUID uuidgen

Copied to following path:

echo "dfb10ba0-dc20-4022-ab31-0f52be4dcabe" | sudo tee /var/lib/docker/volumes/mssql-data/_data/.system/instance_id

Comments

0

Here is what I did. Instead of using the docker-managed volume, I am using the files from my machine. Eg:` db: image: "mcr.microsoft.com/mssql/server"

ports:
  - "1233:3244"
environment:
  SA_PASSWORD: "sapassword"
  ACCEPT_EULA: "Y"
volumes:
  - /Users/<your username>/sqlserver/data:/var/opt/mssql/data
  - /Users/<your username>/sqlserver/logs:/var/opt/mssql/logs
profiles:
  - init
  - run
logging:
  driver: none`

instead of

db:
image: "mcr.microsoft.com/mssql/server"
ports:
  - "1233:3244"
environment:
  SA_PASSWORD: "sapassword"
  ACCEPT_EULA: "Y"
volumes:
  - db-data:/var/opt/mssql
profiles:
  - init
  - run
logging:
  driver: none
volumes:
  db-data:

Now you have to give explicit access to sql to do changes to your file system. This can be done by this command.

chmod -R 777 /Users/<your-username>/sqlserver

Hope this helps!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.