Hi, I’ve tried running samba from docker compose on ubuntu server with this resource https://hub.docker.com/r/dockurr/samba I changed the default volume from “- ./samba:/storage” to “- /mnt/my_ext_hdd/my_dir/my_subdir” The container deploys fine, but I get permission error when trying to access the shared volume from windows? Anyone with some suggestionshoew to fix? Thanks

  • Carlos Francisco 🦣@lile.cl
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    3 days ago

    The easy way, but not the most secure: identify GID and UID of files created by your samba docker container with “ls -la”. Then assign ownership of files and directories of shared volume to that user/group "chown -R GID:UID /path/to/shared”

    @basic_user @selfhosted

  • Appoxo@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    3
    ·
    4 days ago

    My advice (if you can): Create a dedicated NAS VM and use samba the native way.
    Or use a dedicated storage server with native samba.

  • foggy@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    ·
    5 days ago

    You’re running into that permission error because of how Docker handles file permissions between the host and the container. It’s by design for security reasons. The user inside the container likely doesn’t have access to the mounted directory unless the UID and GID match what’s on the host. You can work around it, but it’s locked down intentionally.

    Also, what’s the use case here? What do you need file sharing via Samba in a Docker container for? If it’s just about moving files in and out, docker cp or docker exec -it container /bin/bash might be easier.

    • basic_user@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      5 days ago

      Well, I’m not trying to share from within the docker container. I just want to run the samba service from a container. The share is an external hard drive connected to the server. I want to be able to move files to and from the ext hdd from a windows machine.

      • foggy@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        4 days ago

        Okay, the permission error is almost certainly because the Samba process inside the container doesn’t have the right Linux permissions for the host directory /mnt/my_ext_hdd/my_dir/my_subdir.

        On your server running docker, find the numeric UID and GID for that directory: ls -ln /mnt/my_ext_hdd/my_dir/my_subdir

        you likely need to set PUID=<uid_from_step_1> and PGID=<gid_from_step_1> in the environment: section of your docker-compose.yml file for the Samba service.

        Recreate the container (docker compose up -d --force-recreate).

        WARNING: This assumes you are only accessing Samba from within your secure local network. Never expose Samba directly to the internet. Doing so is a major security risk and makes you a target for attacks.

    • sugar_in_your_tea@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      1
      ·
      5 days ago

      Idk about OP, but I want to run all of my exposed services in containers for security benefits, and I use samba to provide an SMB share for Windows clients.

  • BakedCatboy@lemmy.ml
    link
    fedilink
    English
    arrow-up
    3
    ·
    5 days ago

    Have you done the steps under “How do I modify the default credentials?” and “How do I modify the permissions?” from the readme?

    • basic_user@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      1
      arrow-down
      1
      ·
      5 days ago

      I did fiddle with it. I tried putting my server user and password in there, but didn’t get it working.

      • BakedCatboy@lemmy.ml
        link
        fedilink
        English
        arrow-up
        2
        ·
        5 days ago

        What did you set UID and GID to and what is the output of “ls -an” when run inside of the shared directory? You can remove the file names for privacy. I just tested the docker container and it seems to work between my Linux laptop and my windows 11 desktop using this docker compose:

        services:
          samba:
            image: dockurr/samba
            container_name: samba
            environment:
              NAME: "Data"
              USER: "samba"
              PASS: "secret"
              UID: "1000"
              GID: "1000"
            ports:
              - 445:445
            volumes:
              - ./samba:/storage
            restart: always
        

        The files in my shared folder are owned by UID/GID 1000/1000 which is why I put those as my UID/GID, and when I logged in from Windows I entered samba and secret as the password and I was able to access and modify the files in the shared folder.