this post was submitted on 19 Nov 2025
38 points (100.0% liked)

Selfhosted

53070 readers
638 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 2 years ago
MODERATORS
 

I'm new to Docker, but I'm trying to deploy some containers that will need to read and write to a network shared volume. I'm hoping to run things like Navidrome, Immich, and an Arr Stack. The containers are on Ubuntu and my network volume is on a qnap machine. It is discoverable from Ubuntu without issue.

Do I need to mount the shared volume in Ubuntu or can I just refer to it in the Docker Compose file?

I know I need to mention the location of the volume in the Docker Compose file, but I'm not sure how to write that. How do I include the un/pw information for the NAS?

I read about bind mounts in Docker's documentation. Is that what I want to use? Again, how do I include the un/pw information? I'm not sure how to use the commands.

The volume path for the navidrome folder is //tiger-nas/music/music for example.

I appreciate any help.

you are viewing a single comment's thread
view the rest of the comments
[–] jaypg@lemmy.jaypg.pw 11 points 2 days ago (2 children)

You could mount the network share on the host/Ubuntu and then reference it in your docker compose file. It works. I prefer to write the mount in the Docker compose file since it's a bit more portable. Something like this depending on if you're using SMB/CIFS or NFS:

services:
    some_music_app:
        image: music_app_image:latest
    container_name: music_app
    volumes:
      - smb:/some/path/smb/music
      - nfs:/some/path/nfs/music
volumes:
  smb:
    driver_opts:
      type: cifs
      o: "username=${user},password=${pass},uid=1000,gid=1000,vers=3.0"
      device: "//tiger-nas/music/music"
  nfs:
    driver: local
    driver_opts:
      type: nfs
      o: addr=tiger-nas,nolock,soft,rw,nfsvers=4
      device: ":path/to/music/music"

The ${user} and ${pass} in the smb volume definition are variables that you'll need to have in a .env file next to your compose.yaml file. The .env file is just a normal text file with each line setting a value to a variable. Like:

user=my_username  
pass=123_abc_!@#

Then you restrict the permissions of your .env file and you can essentially take a backup of both files and use them on any server with Docker.

[–] kowcop@aussie.zone 3 points 2 days ago

This is the way I do it

[–] modus@lemmy.world 3 points 2 days ago (1 children)

I guess this is one of my big questions. If I mount it in the YAML file, do I still have to mount it in Ubuntu? Thank you for this.

[–] GreenKnight23@lemmy.world 3 points 2 days ago

no, it's actually preferable that you don't.

docker volume manager will actually mount it for you, you can see where using the "docker volume inspect {name}" command.