microsoft / mssql-docker

Official Microsoft repository for SQL Server in Docker resources
MIT License
1.74k stars 760 forks source link

SQL Server Container fails to start on MacOS every other time. #885

Closed gregpakes closed 5 months ago

gregpakes commented 5 months ago

I am using Aspire to orchestrate my application inclusing SQL containers. I don't believe this to be an aspire issue. I have posted the issue on the Aspire Issues list too, but I think it may be more appropriate here (https://github.com/dotnet/aspire/issues/4392).

I am using MacOS Sonoma and Rider.

In my AppHost program.cs I have:

var sql = builder.AddSqlServer("sql", password: dbPassword, port: 63228)
    .WithBindMount("./sqlserverconfig", "/usr/config")
    .WithBindMount("../../../data/secrets","/var/opt/mssql/secrets")
    .WithBindMount("../../../data/data","/var/opt/mssql/data")
    .WithBindMount("../../../data/log","/var/opt/mssql/log")
    .WithEntrypoint("/usr/config/entrypoint.sh")
    .WithHealthCheck()
    .AddDatabase("databasename");

This spins up a SQL Container in Docker Desktop as expected. But every other time it starts up (this is consistent), I get the following error:

2024-06-05T11:43:14.7058715 Starting check for SQL Server start-up at 0, will end at 60
2024-06-05T11:43:17.6143402 2024-06-05 10:43:17.58 Server      Setup step is FORCE copying system data file 'C:\templatedata\model_replicatedmaster.mdf' to '/var/opt/mssql/data/model_replicatedmaster.mdf'.
2024-06-05T11:43:17.6228111 
2024-06-05 10:43:17.61 Server      ERROR: Setup FAILED copying system data file 'C:\templatedata\model_replicatedmaster.mdf' to '/var/opt/mssql/data/model_replicatedmaster.mdf':  5(Access is denied.)
2024-06-05T11:43:17.6238490 ERROR: BootstrapSystemDataDirectories() failure (HRESULT 0x80070005)

If I simply stop the application and restart, it will work (until next time).

If this is not your issue, please can you point me towards where I need to submit this/

gregpakes commented 5 months ago

Closing this as I think it is an Aspire issue.