dockervolumemountdrivecifs

How to mount a shared windows drive in a docker container


I have been trying for the last few days to mount a shared windows drive, with credentials (username and password) in a docker Linux container. Can’t get it done!!

I have tried volumes, but they don’t seem to work with credentials and for a shared drive.

I have also tried bind-mounting, but it seems like there’s no way to provide credentials when doing it this way…

I have tried mounting directly in the docker container with its terminal, which works but it doesn’t mount on startup so it’s not really useful.

Has anyone found a solution to this problem?

Thank you


Solution

  • I was able to solve this by creating a docker volume.

    It took me some time but I’ve found out that you need the right combination of the version and you need to specify the address and domain.

    In my case I used this to create the volume: docker volume create -—driver local -—opt type=cifs —-opt device=//shareddrivename/path/to/drive —-opt o=addr=shareddrivename,username=<username>,password=<password>,domain=chum,vers=3.0 volumeName

    Then I simply linked the container with the volume when creating it, and it mounted the files inside the container!