将卷与基于SQL Server Windows的Docker容器一起使用

时间:2019-12-29 18:02:33

标签: sql-server docker docker-for-windows docker-volume

我正在尝试在Windows Docker容器中设置SQL Server和IIS环境,以设置需要这些服务器的产品。但是在Windows容器中使用卷存在问题。我可以在基于Linux的容器(如Ubuntu)中成功设置Docker SQL Server容器,并且该卷正常工作。但是在尝试了许多不同的操作之后,我仍然无法在Windows容器中使该卷正常工作。容器出现正常,我可以使用Management Studio连接到SQL Server。但是,如果我重新创建容器,数据将不会像在Ubuntu设置中那样持久。我尝试了以下类似的操作,但均无济于事。任何建议将不胜感激。再次,容器工作正常,但数据似乎保留在容器中,而不是主机中。

docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=XXX" -p 1433:1433 --name sql-server1 -v "sqlvolume:C:/Program\ Files/Microsoft\ SQL\ Server/MSSQL14.SQLEXPRESS/MSSQL/DATA" -d microsoft/mssql-server-windows-express

docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=XXX" -p 1433:1433 --name sql-server1 -v "C:/ProgramData/Docker/volumes/sqlvolume:C:/Program\ Files/Microsoft\ SQL\ Server/MSSQL14.SQLEXPRESS/MSSQL/DATA" -d microsoft/mssql-server-windows-express

docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=XXX" -e "MSSQL_DATA_DIR=c:\sql\data" -p 1433:1433 --name sql-server1 -v C:\Users\carlo\Docker\sql\volume:C:\sql\data -d microsoft/mssql-server-windows-express

Docker信息:

Client:
 Debug Mode: false

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 8
 Server Version: 19.03.5
 Storage Driver: windowsfilter
  Windows:
 Logging Driver: json-file
 Plugins:
  Volume: local
  Network: ics internal l2bridge l2tunnel nat null overlay private transparent
  Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
 Swarm: inactive
 Default Isolation: hyperv
 Kernel Version: 10.0 18362 (18362.1.amd64fre.19h1_release.190318-1202)
 Operating System: Windows 10 Pro Version 1903 (OS Build 18362.535)
 OSType: windows
 Architecture: x86_64
 CPUs: 12
 Total Memory: 31.52GiB
 Name: LAPTOP-3NQ5NQS5
 ID: 5SUF:3ZCD:HMCO:YNKM:HAMN:GAMB:2PMA:MHOU:QP7D:NMUD:NGWI:32F3
 Docker Root Dir: C:\ProgramData\Docker
 Debug Mode: true
  File Descriptors: -1
  Goroutines: 35
  System Time: 2019-12-29T12:43:34.7776107-05:00
  EventsListeners: 1
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

0 个答案:

没有答案