Help Connecting Docker Container to Network Drive

Hello, I’m new to docker and have hit a road block. I’m on a rp4 running Ubuntu server and deploying these containers through Portainer if that matters. I’m trying to give a torrent client access to a network drive.

I tried to mount it directly to the container:

volumes:
  BNBNAS:
    driver_opts:
      type: cifs
      o: "username=xxxx,password=xxxx,vers=3.0"
      device: "//${LAN address}/Movies"
  qbittorrent:
    image: "lscr.io/linuxserver/qbittorrent:libtorrentv1"
    container_name: qbittorrent2
    network_mode: "service:gluetun"
    environment:
      - PUID=1000
      - PGID=1003
      - WEBUI_PORT=8080
    volumes:
      - /docker/qbittorrent/config:/config
      - BNBNAS/Movies:/downloads
      - BNBNAS/Temp:/incomplete
  restart: unless-stopped

And received this error:

failed to deploy a stack: parsing /data/compose/34/docker-compose.yml: invalid interpolation format for volumes.BNBNAS.driver_opts.device. You may need to escape any $ with another $. //${LAN ip}/Movies

I also tried adding it as a volume in Portainer and referencing it:

qbittorrent: 
  services:
  image: "lscr.io/linuxserver/qbittorrent:libtorrent"
  container_name: qbittorrent2
  network_mode: "service:gluetun"
  environment:
   - PUID=1000
   - PGID=1003
   - WEBUI_PORT=8080
  volumes:
   - /docker/qbittorrent/config:/config
   - BNBNAS/Movies:/downloads
   - BNBNAS/Temp:/incomplete
   
volumes:
    BNBNAS:
      external: true

Which gives me this error:

Deployment error

failed to deploy a stack: validating /data/compose/38/docker-compose.yml: (root) Additional property qbittorrent is not allowed

Any help would be greatly appreciated.

You can’t use a volume name and path (doc):

The short syntax uses a single string with colon-separated values to specify a volume mount (VOLUME:CONTAINER_PATH), or an access mode (VOLUME:CONTAINER_PATH:ACCESS_MODE).

  • VOLUME: Can be either a host path on the platform hosting containers (bind mount) or a volume name.

For testing, try to put the string in your compose file without templating.

In a home setup I would rather mount the share to the host and the use a bind mount for the folders. That should save some connections when multiple containers need to access the share.

I see what you mean. Thank you. I changed the code around a little and get a santax or this:

failed to deploy a stack: validating /data/compose/48/docker-compose.yml: (root) Additional property Services is not allowed
Services:
  qbittorrent:
      image: lscr.io/linuxserver/qbittorrent:libtorrentv1
      container_name: qbittorrent
      network_mode: "service:gluetun"
      environment:
      - PUID=1000
      - PGID=1003
      - WEBUI_PORT=8080
      volumes:
      - /home/TorrentBox/docker/qbittorrent/config:/config
      - BNBNAS:/downloads     
volumes:
      BNBNAS:

That’s simple, don’t capitalize: