Accessing a Windows CIFS share from Python code running in a Docker container

  cifs, docker, linux, python, smb

I’m trying to access multiple Windows CIFS shares from a Python code that will run in a Docker container. I’ve seen that there are multiple SMB libraries like pysmb and smbprotocol that claim that they can be used to access CIFS shares, but I haven’t managed to get it to work and haven’t seen a single example online where they are used to access CIFS shares.

I know that a solution would be to mount the share on the host and mount it to the container, but I’d rather to avoid that if possible, as the code will need to access multiple shares and not all will be known when the container starts.

Am I missing something? Is there a good way or a good example online on how to access CIFS share from Python code that runs on Linux? (I know that on Windows you can simply open the folder, but I need it to work on Linux).

Source: Docker Questions