Docker Swarm和Windows节点持久存储

时间:2019-09-04 07:23:45

标签: docker docker-swarm docker-for-windows

我们有一个Docker Swarm cluster,其中有LinuxWindows个节点。

当前我们使用Docker version 19.03.1, build 74b1e89

在Linux节点上,我们使用NFS存储,但是在Windows节点上似乎无法实现。

到目前为止我们尝试过的事情:

  • 创建nfs volume会导致错误options are not supported on this platform

  • 设置nfs共享之前启动服务会给出错误invalid volume specification … invalid mount config for type "bind" … source path does not exist ...

  • 使用SMB Global Mapping会显示错误The parameter is incorrect

SMB Global Mapping创建了V:的共享

$secpasswd = ConvertTo-SecureString 'test' -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential ("test", $secpasswd)
New-SmbGlobalMapping -RemotePath \\192.168.100.100\tmp -Credential $creds -LocalPath V:

并使用以下docker-compose

version: '3.7'

services:
  smb:
    image: mcr.microsoft.com/windows/servercore/iis:windowsservercore-1903
    volumes:
      - V:\poc:C:\inetpub\wwwroot
    ports:
      - 8080:80
    networks:
      - default

networks:
  default:

这是错误消息:

ERROR: for smb  Cannot start service smb: hcsshim::CreateComputeSystem f7d850c78830cb6c0933dc1b4d95035ace6e8d712fb37db24896311f52e2db90: The parameter is incorrect.
(extra info: {"SystemType":"Container","Name":"f7d850c78830cb6c0933dc1b4d95035ace6e8d712fb37db24896311f52e2db90","Owner":"docker","IgnoreFlushesDuringBoot":true,"LayerFolderPath":"C:\\ProgramData\\Docker\\windowsfilter\\f7d850c78830cb6c0933dc1b4d95035ace6e8d712fb37db24896311f52e2db90","Layers":[{"ID":"945ed3ff-4e7f-58e9-b88f-c87c850cc81e","Path":"C:\\ProgramData\\Docker\\windowsfilter\\a240ba3f3c05dab6080c1e01fd0b3692f1731247a77b8be965c81671631eb223"},{"ID":"a2b23cbc-2bc6-549a-a6d3-568f5aa1ba1e","Path":"C:\\ProgramData\\Docker\\windowsfilter\\19595266d37a2d38b4d19c3f5dcc91c1a52c64808d589df00f0a383edf1e317a"},{"ID":"73d26471-1e22-5d8a-b948-6f8effff0dcf","Path":"C:\\ProgramData\\Docker\\windowsfilter\\4e8597b8eb2ce54456d622e9ff82d5c0f52c8e137495f86f6adf8a0d4d692a7e"},{"ID":"ebe5a7a6-7821-5098-865b-75bc9cdca278","Path":"C:\\ProgramData\\Docker\\windowsfilter\\46e64689e93c40d6634b136c2242cfea6e253cf05f02838c4bfb57d10a999b91"},{"ID":"a64e3b2e-ccdd-5f5e-b342-99226d4c6991","Path":"C:\\ProgramData\\Docker\\windowsfilter\\b074eb9cfdf114ecaaf6a0104a710cdb3abc41f93f4dbd6161681df443c07188"}],"HostName":"f7d850c78830","MappedDirectories":[{"HostPath":"v:\\poc","ContainerPath":"c:\\inetpub\\wwwroot","ReadOnly":false,"BandwidthMaximum":0,"IOPSMaximum":0,"CreateInUtilityVM":false}],"HvPartition":true,"EndpointList":["60F1BA39-5E74-41A0-84C7-C0F76680E78F"],"HvRuntime":{"ImagePath":"C:\\ProgramData\\Docker\\windowsfilter\\46e64689e93c40d6634b136c2242cfea6e253cf05f02838c4bfb57d10a999b91\\UtilityVM"},"AllowUnqualifiedDNSQuery":true})
ERROR: Encountered errors while bringing up the project.

有人对如何在Docker Swarm集群中的Windows节点上使用持久性存储有解决方案吗?

1 个答案:

答案 0 :(得分:0)

按照#3所述运行powershell命令之前,需要在Windows功能中启用SMB文件共享。

SMB Feature

启用此功能后,请确保共享文件夹并添加必要的安全权限。

这之后必须运行以下命令

  1. $ creds =获取凭据

  2. New-SmbGlobalMapping -RemotePath \ SERVER \ SharePath $ creds -LocalPath驱动器: