How to map LAN network share to Docker volume?

To not bloat the required capabilities unnecessarily, the recommended approach is to use volumes instead (pointing to your CIFS shares) and map them into a folder inside the container, then use them in your containerized app as you would use any local folder.

Either create your volume first and then use it in docker run commands:

docker volume create \
    --driver local \
    --opt type=cifs \
    --opt o=username={smbuser},password={smbpass},uid={UID for mount},gid={gid for mount},vers=3.0 \
    --opt device=//Share1/FolderMix \

or declare it in a docker-compose.yml:

      type: cifs
      o: username={smbuser},password={smbpass},uid={UID for mount},gid={gid for mount},vers=3.0
      device: //Share1/FolderMix

Make sure to use valid credentials for smbuser/smbpass and that the uid/gid matches those of the user inside the container that start your application inside the container.

1 Like