ishi
ishi

Reputation: 3

Mounting a remote folder from server into a local docker container

I have a bit of a conundrum with mounting a remote folder here.

What we have is a PC in an active directory, as well as a remote server in the same active directory. In order to get files for the script, we need to mount a folder from the remote server into a docker container (using ubuntu 20.04).

So far we've tried to directly mount the folder into the container using WebDAV, but this didn't work saying that the directory of remote folder doesn't exist. Then we tried to first mount it locally through WSL using the mount command so docker could see the mounted folder on the local pc, but this didn't work either: in this case error said that instead, the folder that didn't exist was the target directory (even though it was created in advance).

The question at hand is, what would be the best and most correct way to mount a remote shared folder that is accessible with URL link to a docker container?

Upvotes: 0

Views: 5108

Answers (1)

matic1123
matic1123

Reputation: 1119

we have a similar issue/use case, but in our case, it was possible to create a Samba 4 share on the host where we had a folder with some .pdf documents to "work with".

We then created a docker volume with SMB share (on the host). With the:

docker volume create --driver local --opt type=cifs --opt device=//192.168.XX.YY/theShare --opt o=username=shareUsername,password='sharePassword',domain=company.com,vers=3.0,file_mode=0777,dir_mode=0777 THE_SHARE" command.

Note: we have centos 7 still on that host running docker (where we need samba mount) so we had to install some dependencies on the host system:

sudo yum update
sudo yum install samba-client samba-common cifs-utils

Then in a container, we simply mounted a volume (using -v)

-v THE_SHARE:/mnt/the_share

and inside application it can refer to the content using local RW to the file system on the /mnt/the_share path.

Upvotes: 1

Related Questions