How to use Docker plugin for access a network share?

Same over here.

The following anwser will apply for Linux containers. I am uncertain if the syntax for mounts will be identical for Windows container - if so, somone else will need to pitch in.

This is an example of how to declare volumes in your docker-compose.yml:

volumes:
  remote-share1:
    driver_opts:
      type: cifs
      o: username={useraccount},password={password},uid={mounted with user id},gid={mounted with group ip},vers=3.0
      device: //{hostname or ip}}/{share}/{folder}

Make sure username and password match an account that is actualy allowed to access the share. uid/gid declare which ids are used for the mountpoint (they must match the ids inside the containers). The mount options can take all options ‘mount -t cifs’ accept.

With example values:

volumes:
  remote-share1:
    driver_opts:
      type: cifs
      o: username=meyay,password=somepassword,uid=1001,gid=100,vers=3.0
      device: //192.168.200.20/myshare/my_volume_data

Once the volume is declared, you can use it in a service volume mapping:

version: '3.7'
services:
  myservice:
     ...
      volumes:
        - type: volume
          source: remote-share1
          target: /path/in/container
     ...
1 Like