How to use Docker Volume plugins.

SONM supports several ways for data transfer. The easiest way to do this is to use the BTFS and CIFS Docker volume plugins.

CIFS Plugin

To use CIFS plugin you need access to working Samba server. If you don't have one — you'll need to configure it first. CIFS plugin mounts shared directories content at specified mount point.

How to use

Config your container: section in task description file(task.yaml): Add subsections volumes: and mounts: as follows:

  volumes:
    cifs:
      type: cifs
      options:
        share: <samba.serv.com/share>
        username: <username>
        password: <password>
  mounts:
    - cifs:<mount_point>:<mount_mode>

You need to define following variables here:

  • samba.serv.com/share - samba server location and shared directory name.
  • username - username for shared directories access, defined in Samba-server config.
  • password - password for shared directories access, defined in Samba-server config.
  • mount_point - locates where shared directories will be mounted inside the container.
  • mount_mode - sets mode for filesystem mounting. Could be Read-Only(ro) and Read-Write(rw).
  • security - optional. Set security authentication protocol if it was changed on Samba-server config.
  • vers - optional. Set SMB protocol version if it was changed on Samba-server config.
Example of defined task.yaml
container:
  image: httpd@sha256:b5f21641a9d7bbb59dc94fb6a663c43fbf3f56270ce7c7d51801ac74d2e70046
  commit_on_stop: false
  volumes:
    cifs:
      type: cifs
      options:
        share: 46.101.106.116/share/
        username: sonm
        password: pass
  mounts:
    - cifs:/mnt/samba:ro

This task.yaml example will launch Httpd container from whitelist and mount shared folder Share from 46.101.106.116 at /mnt. Note that due security reasons Read-Write mode for this particular shared folder on 46.101.106.116 is disabled. On your own Samba server you can change that and mount your shared directory in any mode.

BTFS Plugin

General Info:

BTFS, is the acronym for bittorent filesystem. Using BTFS, you can mount magnet link as a directory and then use it as any read-only directory in your file tree. The contents of the torrent file or magnet link will be mounted inside the directory of your choice. When a program tries to access the file for reading, the actual data will be downloaded on demand. Furthermore, tools like ls, cat and cp works as expected.

Possible usecases:

In case you need to transfer large amount of data to multiple instances - BTFS will be much faster than CIFS. Note that BTFS mounts directories in Read-only mode. So if you need to pull results of computation back - you need to use different ways to get it.

How to use

Config your container: section in task description file(task.yaml): Add subsections volumes: and subsection mounts: as follows:

volumes:  
  btfs:    
    type: btfs      
    options:      
      magnet: "<magnet_link>"        
mounts:    
    - btfs:<mount_point>:ro     

You should define magnet_link and mount_point here - contents of magnet_link will be mounted at mount_point. Default mount point is /mnt. You can create magnet link by any convenient Bittorrent client(UTorrent/Transmission for example).

Important! Note that mounting BTFS volume may take some time: it can take about ~10-15 seconds. Your application should check if data is mounted before working with it.

Example of defined task.yaml
container:
  commit_on_stop: false
  image: httpd@sha256:b5f21641a9d7bbb59dc94fb6a663c43fbf3f56270ce7c7d51801ac74d2e70046
  volumes:
    btfs:
      type: btfs
      options:
        magnet: "magnet:?xt=urn:btih:9635cabd201a92fda5d6c70d35cbfb707e290589&dn=ubuntu-18.04.1-live-server-amd64.iso&tr=http%3A%2F%2Ftorrent.ubuntu.com%3A6969%2Fannounce&tr=http%3A%2F%2Fipv6.torrent.ubuntu.com%3A6969%2Fannounce"
  mounts:
    - btfs:/mnt:ro

This task.yaml example will launch Httpd container from whitelist and mount Ubuntu 18.04 Server installation disk inside /mnt