Docker Windows容器和NFS卷

时间:2019-05-16 14:06:54

标签: docker docker-composed

我已经成功创建了一个Windows Docker映像,并且可以使用docker-compose成功运行该容器,为实现全部功能,应用程序希望存在一个文件夹位置,该位置当前是一个NFS附加驱动器,其中包含一个文件夹,应用程序对其他应用程序进行读写,并且也被其他应用程序使用。

我试图找到有关Windows的Docker,Windows容器和NFS卷的Docker Compose的有效示例和文档。

这是我目前正在尝试的

version: "3.4"

services:
  service:
    build:
      context: .
      dockerfile: ./Dockerfile
    image: imageName
    ports:
      - 8085:80
    environment:
      -
    volumes:
      - type: volume
        source: nfs_example 
        target: C:\example
        volume:
          nocopy: true
volumes:
  nfs_example:
    driver: local
    driver_opts: 
      type: "nfs"
      o: "addr=\\fileserver.domain,nolock,soft,rw"
      device: ":\\Shared\\Folder"

我收到的错误消息是:

ERROR: create service_nfs_example: options are not supported on this platform

1 个答案:

答案 0 :(得分:0)

NFS不起作用。我在主机上使用SMB解决了该问题,然后挂载了该卷。

New-SmbGlobalMapping -RemotePath \\contosofileserver\share1 -Credential Get-Credentials -LocalPath G:
version: "3.4"

services:
  service:
    build:
      context: .
      dockerfile: ./Dockerfile
    image: imageName
    ports:
      - 8085:80
    environment:
      -
    volumes:
      - type: bind
        source: G:\share1
        target: C:\inside\container

This microsoft documentation on the windows containers helped me achieve this.

相关问题