How to create data volume in Docker for Windows 10 when using Windows Containers (as opposed to Linux Containers)

Folks, My OS is Windows 10 and I am running Docker version 17.06.0-ce-win19. I have SQL Server express running in a Windows container and I want to persist SQL data within a data volume that I would like to be located in my host file system. I don’t know how to go about creating this data volume and associating it with my container.

Any examples I have seen are using Linux containers and “Shared Drive” properties under Docker/Settings. There are no “Shared Drive” settings when you are running a Windows Container (Hyper-V).

I think this is covered in the README for the image:

docker run -d -p 1433:1433 -e sa_password=<SA_PASSWORD> -e ACCEPT_EULA=Y -v C:/temp/:C:/temp/ -e attach_dbs="[{'dbName':'SampleDb','dbFiles':['C:\\temp\\sampledb.mdf','C:\\temp\\sampledb_log.ldf']}]" microsoft/mssql-server-windows

https://hub.docker.com/r/microsoft/mssql-server-windows/

1 Like