I’m trying to switch my existing Docker setup to a rootless podman one. The main issue tripping me is how to mount remote volumes. My file server is a different machine, so I mount the data into docker containers via a NFS volume. However, I can’t do this with podman since the normal user doesn’t have the rights for mounting NFS drives. Only the root user can do that.

One option I’ve thought of is to mount everything I need via fstab and use bind mounts. Is there a better solution?

  • Im_old@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    ·
    1 year ago

    I use fstab, seems cleaner instead of relying on podman. Otherwise can you give the podman user permissions to mount volumes?

  • 30021190@lemmy.cloud.aboutcher.co.uk
    link
    fedilink
    English
    arrow-up
    1
    arrow-down
    1
    ·
    1 year ago

    I’ve had issues with this too and reverted back to rooted docker. I even tried podman and system NFS mounts that it binds too with varying issues.

    It looks like you can’t actually do this with podman for varying reasons.

  • vegetaaaaaaa@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    ·
    1 year ago

    It’s not possible to mount NFS shares without root (a rootful container would work but I don’t recommend it). Docker allows it because it implicitly runs as root. Cleanest solution is to mount it from the host’s fstab and use a bind mount.

  • lemmyvore@feddit.nl
    link
    fedilink
    English
    arrow-up
    3
    arrow-down
    1
    ·
    1 year ago

    You can mount NFS shares as non-root user, look it up some more.

    What trips people is that it needs some extra configuration on both server and client, the UID needs to match, and the user needs to own the mountpoint dir.

    The error message from NFS (“only root can do that”) doesn’t help either.

  • tablejumper@feddit.nlOP
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    1 year ago

    Update: I took some suggestions and ideas from the comments here and built a system for this:

    • Create the mountpoint directories
    • Add the mounts to /etc/fstab with the user,noauto option
    • I’m using quadlets, so add a new [service] section to my container file and add ExecStartPre and ExecStopPost entries with mount and umount commands
    • Add bind mount volumes to the NFS shares pointing to the local mountpoint

    This allows me to have the mounts only active when the container is running. And I can still have rootless podman containers. Seems to be working well in the limited testing I did yesterday.