user1472131
user1472131

Reputation: 421

mounting a network location to a windows docker container with docker-compose

I am trying to mount a network location of this type \host\folder to a windows docker container. I found few solutions out there but none seems to work:

This following one works on linux containers but not on windows one:

services:
  myservice:
    volumes:
      - NetworkLocation: c:/app/MountedLocation
volumes:
  NetworkLocation:
    driver_opts:
      type: cifs
      device: "\\host\folder"
      o: username=username,password=pw,rw

I also found this, that is described as the correct way for windows containers:

services:
  volumes:
    - type: bind
      source: //host/folder
      target: c:/app/MountedLocation

In this case I get an error from docker saying that //host/folde is an invalid mount path, mount path must be absolute.

Any suggestions?

Upvotes: 0

Views: 78

Answers (1)

Kevin Kopf
Kevin Kopf

Reputation: 14230

As far as I know, windows primarily uses server message block, or SMB. If you take a look at driver_opts documentation, you can derive it from there:

volumes:
  example:
    driver_opts:
      type: "smb"
      o: "addr=10.40.0.199,nolock,soft,rw"
      device: ":/docker/example"

Upvotes: 0

Related Questions