I have found the Docker plugin for access network share from docker:
How I can use it ? Should I build it?
Share and learn in the Docker community.
I have found the Docker plugin for access network share from docker:
How I can use it ? Should I build it?
The build-in local driver is able to mount NFS and CIFS as well.
What kind of remote share are your trying to mound and how do you want to use it (within cli commands or docker-compose)?
I have a Windows-based LAN: Domain controllers+workstations.
Some of workstations have shares for common usage.
I develop cross-platform web app which by idea will be packed to docker and provided to user.
[User] queries->http://localhost:5001/GetFileList=SharePath and this app enumerate files from the path and returns to user.
I set permissions to this share as Everyone Full-Access.
The original task is:
The dockerized app should connect to external database, read share paths (N), enumerate files and return the file list to user.
You answered this with “I have a Windows-based LAN: Domain controllers+workstations. Some of workstations have shares for common usage.”, so CIFS it is then.
What about this part of the question?
Sorry, there is hot summer in our region, I have passed it.
I am going to provide my docker image with my app and docker-compose file. It will include ELK dockers to keep logs with additional settings etc.
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
...
Thank you! WiIl try this way.
Obviously
I never had shares accessible by everyone. Thus, I have no experience if it works without credentials. Though, I mentioned mount -t cifs
options as a hint to read the man page or google for it.
Yet another question:
Is it possible to access to share from dockerized app dynamically?
I.e. the app runs in Docker, it reads share path from a database then mount it, enumerate files etc.
The database can contain 10-100 shares paths. To access them user needs to read all shares from a db, then edit docker-compose file etc etc.
Nope, dynamical mounting and containers are not a good fit. In order to actualy mount shares in a container, it needs to be run in priveleged mode. Fun fact: privileged mode is not suported by Docker Swarm Stacks/Services.
From what it looks like, you should look for a different approch and leverage the docker api directly in your app, to build up things dynamicly as required. The docker-compose approach does not allow that level of dynamic configuration that you are looking for.