External Volumes Mounting Question

Hi - I have a pretty basicc question but I can’t seem to figure it out on my own or find any documentation on my specific request.

I have mapped my smb shares in docker using the below docker compose parameters (where x is obviously my specific values):

  volume_1:
    driver_opts:
      type: cifs 
      o: username=xxx,password=xxx,uid=xxx,gid=xxx,vers=3.0
      device: //xxx.xxx.xxx.xxx/path/to/media

This all works fine and I can point to the path in the device and succcessfully map the drive. However, there are some containers that only need to point to a specific folder on this path - eg. “path/to/media/folder1” - in my docker compose file, if I try to use the below, I get a fail:

    volumes:
       - volume_1/folder1:/folder1

What am I doing wrong and is there a way I can point to a specific folder or do I have to set up a volume for eacch individual folder I want to point to?

I feel like the solution should be simple, but I just can’t figure it out

You can not map a volume’s subfolder into a container.

If you don’t want to expose a share and all its subfolders, you will need to create a cifs backed volume for each subfolder of the remote share.

IT would look something like this:

services:
  myservice:
    volumes:
      - volume1:/container/folder1
      - volume2:/container/folder2
   ...

volumes:
  volume1:
    driver_opts:
      type: cifs 
      o: username=xxx,password=xxx,uid=xxx,gid=xxx,vers=3.0
      device: //xxx.xxx.xxx.xxx/path/to/media/folder_1
  volume2:
    driver_opts:
      type: cifs 
      o: username=xxx,password=xxx,uid=xxx,gid=xxx,vers=3.0
      device: //xxx.xxx.xxx.xxx/path/to/media/folder_2

Note: volume configurations are immutable. Changes in the compose file are not reflected back to the volume configuration. In order to update a volume, it needs to be removed, and re-created by compose.