microsoft / mssql-docker

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

Cannot persist master in microsoft/mssql-server-windows-developer #350

Open swasheck opened 6 years ago

swasheck commented 6 years ago

I cannot find a way to persist master using the windows-developer image. I've tried the linux configuration environment commands but containers always come up with "C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\" as the default location.

This is trivial with volumes in the linux image, but the default installation location for windows is presenting challenges.

Example using volumes:

docker run --name testcontainer -d -p 1433:1433 -v sql_system:"c:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\" -e sa_password=MyPassword123 -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer

throws: "docker run" requires at least 1 argument.

So I assume that the "\" is escaping the string.

docker run --name testcontainer -d -p 1433:1433 -v sql_system:c:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\ -e sa_password=MyPassword123 -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer

is a non-starter because of the spaces

docker run --name testcontainer -d -p 1433:1433 -v sql_system:"c:/Program Files/Microsoft SQL Server/MSSQL14.MSSQLSERVER/MSSQL/DATA" -e sa_password=MyPassword123 -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer

throws: docker: Error response from daemon: container c1d6ce64883e954afbf383fb1302f1bc102ca6981d55ac1bdc55db1f041566b3 encountered an error during Start: failure in a Windows system call: The compute system exited unexpectedly. (0xc0370106)

docker run --name testcontainer -d -p 1433:1433 -v sql_system:"c:\\Program Files\\Microsoft SQL Server\\MSSQL14.MSSQLSERVER\MSSQL\\DATA" -e sa_password=MyPassword123 -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer

throws: docker: Error response from daemon: invalid volume specification: 'sql_system:c:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA'.

Attempt to do this using the Linux configuration options (a long shot)

docker run --name testcontainer -d -p 1433:1433 -v mssql_sysdb:c:/mssqldata/system -v mssql_tempdb:c:/mssqldata/tempdb -e "SA_PASSWORD=MyPassword123" -e "ACCEPT_EULA=Y" -e "MSSQL_MASTER_DATA_FILE=c:/mssqldata/system/master.mdf" -e "MSSQL_MASTER_LOG_FILE=c:/mssqldata/system/mastlog.ldf" -e "MSSQL_DATA_DIR=c:/mssqldata/data" -e "MSSQL_LOG_DIR=c:/mssqldata/logs" microsoft/mssql-server-windows-developer

Container runs, but non of those options are considered and master is placed in "C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\"

To verify master is not persisted, I created a new login (TestLogin), killed and removed the container. Ran the container again and the login is not there.

twright-msft commented 6 years ago

This seems like just a quote parsing issue. Try this: docker run --name testcontainer -d -p 1433:1433 -v "sql_system:'c:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\'" -e sa_password=MyPassword123 - e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer

swasheck commented 6 years ago

Thanks for the suggestion. result:

C:\Program Files\Docker\Docker\Resources\bin\docker.exe: invalid reference format.

dnzhnshn commented 5 years ago

is this issue solved ?