Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Selfhosted
  3. samba docker compose help

samba docker compose help

Scheduled Pinned Locked Moved Selfhosted
selfhosted
13 Posts 8 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Guest

    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 fro windows?
      Anyone with some suggestionshoew to fix?
      Thanks
    B This user is from outside of this forum
    B This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #4

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

    ? 1 Reply Last reply
    0
    • ? Guest

      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 fro windows?
        Anyone with some suggestionshoew to fix?
        Thanks
      F This user is from outside of this forum
      F This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #5

      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.

      S ? 2 Replies Last reply
      0
      • F [email protected]

        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.

        S This user is from outside of this forum
        S This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #6

        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.

        1 Reply Last reply
        0
        • F [email protected]

          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.

          ? Offline
          ? Offline
          Guest
          wrote on last edited by
          #7

          Well, I'm 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.

          F 1 Reply Last reply
          0
          • B [email protected]

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

            ? Offline
            ? Offline
            Guest
            wrote on last edited by
            #8

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

            B 1 Reply Last reply
            0
            • ? Guest

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

              B This user is from outside of this forum
              B This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #9

              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.

              1 Reply Last reply
              0
              • ? Guest

                Well, I'm 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.

                F This user is from outside of this forum
                F This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #10

                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.

                1 Reply Last reply
                0
                • ? Guest

                  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 fro windows?
                    Anyone with some suggestionshoew to fix?
                    Thanks
                  appoxo@lemmy.dbzer0.comA This user is from outside of this forum
                  appoxo@lemmy.dbzer0.comA This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #11

                  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.

                  1 Reply Last reply
                  0
                  • ? Guest

                    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 fro windows?
                      Anyone with some suggestionshoew to fix?
                      Thanks
                    carloshr@lile.clC This user is from outside of this forum
                    carloshr@lile.clC This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #12

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

                    @basic_user @selfhosted

                    ? 1 Reply Last reply
                    1
                    0
                    • carloshr@lile.clC [email protected]

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

                      @basic_user @selfhosted

                      ? Offline
                      ? Offline
                      Guest
                      wrote on last edited by
                      #13

                      Do I just enter the container shell and check GID and UID of a random file?

                      1 Reply Last reply
                      0
                      • System shared this topic on
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups