Docker Community Forums

Share and learn in the Docker community.

Docker-compose - Nfs share

Hello i’m trying to mount files from a qnap
directly in a docker-compose.yml with plex

I’m beginner and i’m trying to understand what i do…

That’s the part of a docker-compose.yml i’m trying to adapt at my case.

[root@docker docker-mirror]# cat nfs-compose.yml
version: "3.2"

services:
     rsyslog:
       image: jumanjiman/rsyslog
       ports:
         - "514:514"
         - "514:514/udp"
       volumes:
         - type: volume
           source: example
           target: /nfs
           volume:
             nocopy: true
volumes:
     example:
       driver_opts:
         type: "nfs"
         o: "addr=10.40.0.199,nolock,soft,rw"
         device: ":/docker/example"

And my try is :

version: "2.1"
services:
  plex:
    image: linuxserver/plex
    container_name: plex
    network_mode: host
    environment:
      - PUID=1001
      - PGID=1001
      - VERSION=docker
      - UMASK_SET=022 #optional
      - PLEX_CLAIM= #optional
    volumes:
      - /opt/docker/plex/config/:/config
      - type: volume
          source: souvenir
          target: /plex/souvenir ## file from Nas
          volume:
            nocopy: true ## i don't want that the container download my file, i prefer keep them on Nas
volumes:
  souvenir:
    driver_opts:
         type: "nfs"
         o: "addr=xx.xxx.xx.xx,nolock,soft,rw"
         device: ":/opt/docker/plex/data/prive/souvenir"
    
    restart: unless-stopped

I have created an account on Nas, and on host only for plex it’s : media

I don’t know if i’m doing it well, but i’m trying my best.
I could put them on fstab, but i’m not sure that’s is a good idea of sharing all my file in Host.
And i have had problem in a Vm, that at reboot my nas files aren’t mount .

Sorry for my english, i’m trying my best.
Thank’s for help.

Ps: i’m trying to understand what i’m doing, so if someone car explains what i do wrong .
And i have to add more than one nfs share, how to add more than one .

Your “device” delaration looks like you either didn’t create an nfs export (aka share) or have no idea how to use it. Please follow https://www.qnap.com/de-de/how-to/knowledge-base/article/how-to-enable-and-setup-host-access-for-nfs-connection/ on how to create an nfs share. If the share does not exist yet, please create it before the step Edit Shared Folder Permission": create -> Shared Folder. Whatever you define as Folder Name will be the name of the export. Set the Path to “Enter path manualy” and paste the path you want to use.

Example:

Folder Name: test
Share: /opt/docker

then your device declaration would be: “:/test/plex/data/prive/souvenir”.

Appart from that: I am not realy sure what your post is about. It looks like scrapbook notices to me :slight_smile:

Thanks for you response: @meyay

This system was running on a VM with PMS,
and i have created for the older share you are right.

Now the part of Qnap is done,
i’m not sure that my docker-compose is good, because i have an error line 16 en 1
docker-compose up -d

Thanks for your help, so in second part it’s location of nas directory ?

I’ll corrige that and test.

Edit :slight_smile:

ERROR: yaml.scanner.ScannerError: mapping values are not allowed here
  in "./docker-compose.yml", line 16, column 17
    volumes:
      - /opt/docker/plex/config/:/config
      - type: volume
          source: souvenir
          target: /nfs
          volume:
            nocopy: true
volumes:
  souvenir:
    driver_opts:
         type: "nfs"
         o: "addr=192.xxx.x.xx,nolock,soft,rw"
         device: ":/share/plex/souvenir"

    restart: unless-stopped

The needed, is that my container can read my qnap directory in direct nfs.
I’m trying to understand how to configure it …
Container directory is /opt/docker/plex/…
Nas share is /share/plex/…

I am not sure if it’s possible to mix the short and long version of volume declaration. Also your nocopy settings has absolutly zero effects. It would copy preexisting data in the images /config folder back to the volume and then mount the volume “on top”, so that olny the mounted folder would be visible.

I still don’t realy understand your situation. Maybe QNAP has a forum in your native language?

@meyay

I didn’t found an active forum for Qnap user in french …

My configuration looks like wrong if i understand what you said.
I want a local directory: for only plex config
and mount folder from my qnap in their folder each other

/Nasfolder1/xxx mounted on /containerfolder/folder1

I would like to read only files from qnap. Not to import them in the container.

Plex only need a read access.


I have spend my time today trying to mount into /etc/fstab

I have installed nfs-common

And i have something like that :

qnapip:/plex/souvenir        /nas/souvenir       nfs4    auto,defaults,nofail,_netdev 0 0

When i use

mount -a

It works fine, with the command df, i can see the folder is mounted in my Vm
And when i reboot for testing if it’s mount auto at restart
I can’t see them again.

I have found it in syslog :

 Aug 21 23:38:33 plex systemd[1]: Mounting /nas/souvenir…
Aug 21 23:38:33 plex systemd[1]: nas-souvenir.mount: Mount process exited, code=exited status=32
Aug 21 23:38:33 plex systemd[1]: Failed to mount /nas/souvenir.

But if i use again mount -a
The folder is again mount --’.

So i try a lot of things for mount that folder, but nothing work fine :\

Sorry but thanks for your help …

How is the whole fstab/mount information related to docker? Plex is running in a container, isn’t?

If so, the docker volume declaration in your docker-compose.yml already does what you want. There is no need to additionaly mount anything from the os - at least it would make your volume declaration superflous.

Though, there is one catch: a volume declaration is immutable once it’s created. You need to delete your volume in order to let docker create a new one with the changed configuration!
Stop your compose deployment, then execute docker volume rm souvenir, then redeploy your compose deployment.

Good luck!

@meyay the solution was on adding :slight_smile:

auto,x-systemd.automount,x-systemd.device-timeout=3,_netdev,defaults,nodev,nosuid,noexec  0 0

option on Fstab.

You need to install :slight_smile:

apt-get install network-manager
and enable the service.
now it’s work fine :slight_smile:
systemctl enable NetworkManager-wait-online.service