Attach existing database files to SQL Server running on Docker for Windows

0

I'm trying to attach an already existing SQL Server database to a Microsoft SQL Server Developer for Windows Containers (see here). I'm using Docker for Windows (v2.2.0.0) on Windows 10 (Build 18363). I can successfully run the following command:

docker run -d -p 1433:1433 --name mssql -e sa_password=SoSecret0815 -e ACCEPT_EULA=Y -e attach_dbs="[{'dbName':'MyDatabase','dbFiles':['C:\\temp\\SQLServer\\MyDatabase.mdf','C:\\temp\\SQLServer\\MyDatabase_log.ldf']}]" microsoft/mssql-server-windows-developer

However, when connecting to the instance using SQL Server Management Studio, my database MyDatabase is not attached.

The following commands with four \ also runs fine, but after some time, the container simply disappears/dies:

docker run -d -p 1433:1433 --name mssql -e sa_password=SoSecret0815 -e ACCEPT_EULA=Y -e attach_dbs="[{'dbName':'MyDatabase','dbFiles':['C:\\\\temp\\\\SQLServer\\\\MyDatabase.mdf','C:\\\\temp\\\\SQLServer\\\\MyDatabase_log.ldf']}]" microsoft/mssql-server-windows-developer

Furthermore, I tried to mount the folder as a volume in the following ways:

  • -v C:\temp\SQLServer\C:/temp/SQLServer
  • -v C:\temp\SQLServer\:/c/temp/SQLServer

All lead to the same error: invalid volume specification:

I've also tried:

docker run -d -p 1433:1433 --name mssql -v C:\temp\SQLServer:C:\temp\SQLServer -e sa_password=SoSecret0815 -e ACCEPT_EULA=Y -e attach_dbs="[{'dbName':'MyDatabase','dbFiles':['C:\\\\temp\\\\SQLServer\\\\MyDatabase.mdf','C:\\\\temp\\\\SQLServer\\\\MyDatabase_log.ldf']}]" microsoft/mssql-server-windows-developer

C:\Program Files\Docker\Docker\resources\bin\docker.exe: Error response from daemon: container 44b12683aa4b090106ad2d84484c3c56e3486df4de6086eb5254331d3573fe73 encountered an error during Start: failure in a Windows system call: The virtual machine or container exited unexpectedly. (0xc0370106).

Any ideas?

sql-server
docker
asked on Stack Overflow Jan 30, 2020 by mu88 • edited Jan 30, 2020 by mu88

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0