2

I'm using docker v20.10.17 in a windows system. I'd like to run a container (jupyterhub/jupyterhub) and mount a directory into it to share data (for all users with write permission inside the container system).

The shared directory is from another NAS (//192.168.1.5/folder/shared_data), which can be opened properly from the host system. I followed the Create CIFS/Samba volumes instruction here to create a samba volume first:

PS C:\Users\Administrator> docker volume create \
--driver local \
--opt type=cifs \
--opt device=//192.168.1.5/folder/shared_data \
--opt o=addr=192.168.1.5,username=myusername,password=mypassword,file_mode=0777,dir_mode=0777 \
--name cif-volume

Which successfully created a volume named cif-volume. Then:

PS C:\Users\Administrator>docker run --rm -it -p 18000:8000 \
--name jhubcontainer \
--cap-add SYS_ADMIN \
--cap-add DAC_READ_SEARCH \
--privileged \
-v cif-volume:/etc/skel/shared_data jupyterhub-image

And I got error message like this:

docker: Error response from daemon: failed to mount local volume: mount //192.168.1.5/folder/shared_data:/var/lib/docker/volumes/cif-volume/_data, data: username=myusername,password=mypassword,file_mode=0777,dir_mode=0777: operation not supported.
See 'docker run --help'.

Need help with this.


Update 2022/11/03 with updated message:

I tried to update my command based on the help of Slava Kuravsky, but still got errors. Within the previous question, I used a pseudo address and username. I'll paste the exact command I used with the real address and username, without any modifications.

PS C:\Users\Administrator> docker volume create --driver local --opt type=cifs --opt device="//172.16.90.50/public/shared_data" --opt o=addr=172.16.90.50,username=212,password=ziyuan,file_mode=0777,dir_mode=0777,vers=2.0 --name cif-volume
cif-volume
PS C:\Users\Administrator> docker run -it --rm -p 18000:8000 --name jhubcontainer -v cif-volume:/etc/skel/shared_data jupyterhub-20221021-mountsmb
docker: Error response from daemon: failed to mount local volume: mount //172.16.90.50/public/shared_data:/var/lib/docker/volumes/cif-volume/_data, data: addr=172.16.90.50,username=212,password=ziyuan,file_mode=0777,dir_mode=0777,vers=2.0: invalid argument.
See 'docker run --help'.
PS C:\Users\Administrator>

The docker image is "jupyterhub/jupyterhub", and "jupyterhub-20221021-mountsmb" is a backup after installed some other python packages and configures.

enter image description here

To make sure the address is accessable, I tried:

PS C:\Users\Administrator> net use m: \\172.16.90.50\public\shared /user:212 ziyuan
命令成功完成。

The printout "命令成功完成" means "Command succeed". And I can see my mounted driver "M:" in explorer

enter image description here

gepcel
  • 1,326
  • 11
  • 21

1 Answers1

1

Add the cifs version to the volume options: vers=2.0

docker volume create \
--driver local \
--opt type=cifs \
--opt device=//192.168.1.5/folder/shared_data \
--opt o=addr=192.168.1.5,username=myusername,password=mypassword,file_mode=0777,dir_mode=0777,vers=2.0 \
--name cif-volume

Worked for me without any additional privileges and capabilities

docker run -it --rm --name cifs -v cif-volume:/mnt ubuntu:latest ls /mnt
Slava Kuravsky
  • 2,702
  • 10
  • 16
  • I still get `Error response from daemon: error while mounting volume`, which seems like a bad address or username. I want to paste my command here, in hope you can help me with this. But a long line of command doesn't show well in the comment. So I modified my question. Can you help me please? Thanks. – gepcel Nov 03 '22 at 00:03
  • You can try to omit addr option by volume creation – Slava Kuravsky Nov 03 '22 at 07:55
  • Got a slightly different error message: ```docker: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/cif-volume/_data': failed to mount local volume: mount //172.16.90.50/public/shared:/var/lib/docker/volumes/cif-volume/_data, data: username=212,password=ziyuan,file_mode=0777,dir_mode=0777,vers=2.0: invalid argument.``` – gepcel Nov 03 '22 at 11:10
  • I don’t know where to find in Windows the log file with details which argument is invalid. If you can’t find it, try to change version to 3.0 or 1.0 (not secure) and play with another options – Slava Kuravsky Nov 03 '22 at 13:54
  • I haven't find any logs, but I enabled smb1.0 client/server and linux subsystem for windows just now, and tested vers=1.0/2.0/3.0. For vers=1.0/2.0, errors still show `invalid argument`, but for vers=3.0, it shows `operation not supported`. – gepcel Nov 04 '22 at 00:03
  • Find out the samba version in windows: in powershell `Get-SmbConnection` – Slava Kuravsky Nov 04 '22 at 09:32
  • By the way, how about using only username, password and vers=2.0 as options? – Slava Kuravsky Nov 04 '22 at 09:35
  • It's strange that `Get-SmbConnection` shows nothing before and after I execute `Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol` and `Set-SmbServerConfiguration -EnableSMB2Protocol $true`, which is supposed to enable both smb1 and smb2. Are there any chances that it's because the host system (windows server 2019) is a virtual machine of vmware? – gepcel Nov 04 '22 at 13:10