ServerContainers / samba

samba - (ghcr.io/servercontainers/samba) (+ optional zeroconf, wsdd2 & time machine) on alpine [x86 + arm]
432 stars 55 forks source link

Not Able to Delete Files #125

Closed ChrisJBurns closed 7 months ago

ChrisJBurns commented 7 months ago

I am getting quite a lot of issues trying to delete files / directories on a Samba share.

I am able to create them without issue, but deleting them is where I just cannot get it to work.

docker-compose.yaml

---
version: "3.9"

services:
  samba:
    image: docker.io/servercontainers/samba:latest
    container_name: samba
    restart: unless-stopped
    # user: samba
    # network_mode: host
    # hostname: smb-server
    environment:

      GROUP_sambausers: 1500

      ACCOUNT_samba: test
      UID_samba: 1000
      GROUPS_samba: sambausers

         ## Groups definition ##

      SAMBA_GLOBAL_CONFIG_server_SPACE_min_SPACE_protocol: NT1
      SAMBA_GLOBAL_CONFIG_ntlm_SPACE_auth: ntlmv1-permitted
      SAMBA_VOLUME_CONFIG_shared_home: |
        vfs objects = catia fruit streams_xattr
        [home];
        path=/shares/home
        valid users = samba
        browsable = yes
        writeable = yes
        read only = no
        inherit owner = yes
        create mask = 777
        directory mask = 777
        force create mode = 777
        force directory mode = 777
        force user = samba
        force group = sambausers
    volumes:
      - ./shares/home:/shares/home
    ports:
      - 445:445
    cap_add:
      - CAP_NET_ADMIN

  myubuntu:
    image: ubuntu
    container_name: ubuntu
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    build:
      dockerfile: Dockerfile
      context: .
    cap_add:
      - SYS_ADMIN
      - DAC_READ_SEARCH

When I docker exec onto the samba container, I can see that the /shares/home is owned by root, I change this using chown -R 1000:1500 shares/

I use a separate Ubuntu container in order to mount the Samba share so I can test it. I originally did this with my Macbook but I had problems there so I wanted to remove the possibility that my Macbook was the problem. This is what is in my Dockerfile for the Ubuntu image:

FROM ubuntu

RUN apt update && apt install -y samba smbclient vim iputils-ping cifs-utils

COPY --chmod=0600 smbcreds /home/.smbcredentials

RUN echo "//samba/home /mnt/home cifs credentials=/home/.smbcredentials,uid=1000,gid=1500 0 0" > /etc/fstab

RUN mkdir -p /mnt/home

# RUN mount -a

Once I do a docker-compose up --force-recreate --build, both samba and ubuntu containers are up. I exec onto my Ubuntu container and run mount -a, i then go to /mnt/home and I can see all of the files/folders there that exist on my Macbook. I can even create files.

root@ee4447359d43:/mnt/home# ls -al
total 32
drwxr-xr-x 2 1000 1500    0 Mar 14 15:07 .
drwxr-xr-x 1 root root 4096 Mar 14 14:08 ..
-rwxr-xr-x 1 1000 1500    0 Mar 14 14:59 .DS_Store
-rwxr-xr-x 1 1000 1500    0 Mar 14 14:53 .hi.file.swp
-rwxr-xr-x 1 1000 1500    0 Mar 14 14:53 .hi.file.swx
-rwxr-xr-x 1 1000 1500    0 Mar 14 15:07 .new.file.swp
-rwxr-xr-x 1 1000 1500    0 Mar 14 15:07 .new.file.swx
-rwxr-xr-x 1 1000 1500    0 Mar 14 14:18 .new.text.swp
-rwxr-xr-x 1 1000 1500    0 Mar 14 14:18 .new.text.swx
-rwxr-xr-x 1 1000 1500 4096 Mar 14 15:07 .newnew.swo
-rwxr-xr-x 1 1000 1500    0 Mar 14 15:07 .newnew.swp
-rwxr-xr-x 1 1000 1500    0 Mar 14 15:07 .newnew.swpx
-rwxr-xr-x 1 1000 1500    4 Mar 14 14:53 hi.file
-rwxr-xr-x 1 1000 1500 4096 Mar 14 14:53 hi_file.swp
-rwxr-xr-x 1 1000 1500    4 Mar 14 15:07 new.file
-rwxr-xr-x 1 1000 1500    5 Mar 14 14:18 new.text
-rwxr-xr-x 1 1000 1500 4096 Mar 14 15:07 new_file.swp
-rwxr-xr-x 1 1000 1500 4096 Mar 14 14:18 new_text.swp

They even show that they are owned by 1000:1500 - which is the samba uid (1000) and sambausers gid (1500). However, I just cannot delete any files/directories. The error I get is

root@375f455c0b84:/mnt/home# rm new.text
rm: cannot remove 'new.text': Operation not supported

The fact that I can write new ones shows that write access is fine, but I have been racking my brains for the last couple of days trying to figure out why deletes don't work. I have tried all sorts of combinations in the smb.conf file. From forcing users, to forcing groups, to using root, to creating 777 masks, nothing I do get's deletes to work.

MarvAmBass commented 7 months ago

Hi there,

long text, super strange issue - I never encountered a similiar issue to be honest.

can you check the filesystem on the host, the permissions should be the same (at least if you look at the ids) also can you remove the files on the host?

it honestly doesn't make sense that you're not able to delete

can you reproduce this with a different client? like a mac, pc or desktop linux?

I suspect that maybe the ubuntu container has some issues - containers have a mutable filesystem which is stacked on top of each other - maybe this is some sort of security mechanism, although you should be able to delete files manually

can you check/list all your options? (i suspected read only mounts, but you said you can create files)

anything strange int the logs? have you tried an older version of this container?

MarvAmBass commented 7 months ago

also maybe you can rety this using this minimal configuration:

I also noted a issue with your configuration please use the vfs like that SAMBA_GLOBAL_STANZA: vfs objects = catia fruit streams_xattr

    environment:
      ACCOUNT_samba: test
      UID_samba: 1000
      SAMBA_GLOBAL_STANZA: vfs objects = catia fruit streams_xattr
      SAMBA_VOLUME_CONFIG_shared_home: |
        [home];
        path=/shares/home
        valid users = samba
        browsable = yes
        writeable = yes

and make sure on the host, that the folder which is created has permissions like chown -R 1000:1000 ./shares/home; chmod -R 700 ./shares/home

ChrisJBurns commented 7 months ago

Hi @MarvAmBass loving the rapid reply ❤️

can you check the filesystem on the host, the permissions should be the same (at least if you look at the ids) also can you remove the files on the host? On my Macbook, this is the result from ls -al

drwxrwxrwx    3 chburns  staff    96 14 Mar 14:02 shares

can you reproduce this with a different client? like a mac, pc or desktop linux? Yep, so I've done it a couple of ways:

1) smbclient on my Mac

Within my Terminal and I connect to the share, it's a similar issue as the above, I can see files and can create directories, just not delete.

> smbclient //chburns-mbp-76/home -U samba
Can't load /usr/local/etc/smb.conf - run testparm to debug it
Password for [WORKGROUP\samba]:
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Thu Mar 14 15:07:49 2024
  ..                                  D        0  Thu Mar 14 15:18:50 2024
  .DS_Store                           H     6148  Thu Mar 14 15:13:41 2024
  .hi.file.swp                        H        0  Thu Mar 14 14:53:07 2024
  .hi.file.swx                        H        0  Thu Mar 14 14:53:07 2024
  .new.file.swp                       H        0  Thu Mar 14 15:07:47 2024
  .new.file.swx                       H        0  Thu Mar 14 15:07:47 2024
  .new.text.swp                       H        0  Thu Mar 14 14:18:56 2024
  .new.text.swx                       H        0  Thu Mar 14 14:18:56 2024
  .newnew.swo                         H     4096  Thu Mar 14 15:07:41 2024
  .newnew.swp                         H        0  Thu Mar 14 15:07:37 2024
  .newnew.swpx                        H        0  Thu Mar 14 15:07:37 2024
  hi.file                             N        4  Thu Mar 14 14:53:09 2024
  hi_file.swp                         N     4096  Thu Mar 14 14:53:09 2024
  new.file                            N        4  Thu Mar 14 15:07:49 2024
  new.text                            N        5  Thu Mar 14 14:18:58 2024
  new_file.swp                        N     4096  Thu Mar 14 15:07:49 2024
  new_text.swp                        N     4096  Thu Mar 14 14:18:58 2024

        488245288 blocks of size 1024. 154643048 blocks available
smb: \> rm new.text
NT_STATUS_NOT_SUPPORTED deleting remote file \new.text
smb: \>

2) Using Finder to connect to the server

Finder >> Connect to Server >> smb://127.0.0.2 Once connected, I can see files, just can't delete image

3) Where I use a Linux / Ubuntu Container

This is what I've mentioned in the issue description where I've stood up a Ubuntu container in the same compose file, and mounted the Samba share via fstab. Can create files, view files, just not delete them or move them.

root@375f455c0b84:/mnt/home# rm new.text
rm: cannot remove 'new.text': Operation not supported
root@375f455c0b84:/mnt/home# mv new.text new.txt
mv: cannot move 'new.text' to '

I can't even edit existing files as I get the following error.

E325: ATTENTION
Found a swap file by the name "new_text.swp"
             dated: Thu Mar 14 14:18:58 2024
         file name: /mnt/home/new.text
          modified: no
         user name: root   host name: a6031722724b
        process ID: 23 (STILL RUNNING)
While opening file "new.text"
             dated: Thu Mar 14 14:18:58 2024

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r new.text"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "new_text.swp"
    to avoid this message.

Swap file "new_text.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

Which options did you want specifically? I think I've outputted all of the ones I'm setting. Or did you want the smb.conf thats on the samba container?

MarvAmBass commented 7 months ago

What kind of hardware device is mounted on the docker host? It just doesn't make sense

You can remove the file on the host directly, am I right? The share is also not mounted in a special unusual way - am I right?

MarvAmBass commented 7 months ago

Maybe you have some special attributes active 'lsattr -a your/path'?

Also maybe some apparmor / selinux policies stand in your way and only allow creating / appending to files.

ChrisJBurns commented 7 months ago

You can remove the file on the host directly, am I right? The share is also not mounted in a special unusual way - am I right?

Yes, I can remove the file on my host, and nope, I mount the folder on the host to the samba share via the docker compose:

    volumes:
      - ./shares/home:/shares/home

Maybe you have some special attributes active 'lsattr -a your/path'?

This is on the samba` docker container:

> docker exec -it samba sh
/ # lsattr -a  /shares/
lsattr: reading /shares/home: Function not implemented
--------------e----- /shares/.
--------------e----- /shares/..

Also maybe some apparmor / selinux policies stand in your way and only allow creating / appending to files.

I don't think that is the case on my Macbook at least

ChrisJBurns commented 7 months ago

In addition to the above, this is the results from running lsattr -a on the Ubuntu container where I am mounting the samba share via fstab.

root@1d00d8e4399a:/mnt/home# lsattr -a
lsattr: Operation not supported While reading flags on ./.
--------------e------- ./..
-uS-ia--c-jI---------m ./.hihi.text.swp
-uS-ia--c-jI---------m ./.hihi.text.swx
-uS-ia--c-jI---------m ./.text.txt.swp
-uS-ia--c-jI---------m ./.text.txt.swx
-uS-ia--c-jI---------m ./hi.text
-uS-ia--c-jI---------m ./hihi.text
-uS-ia--c-jI---------m ./hihi_tex.swp
-uS-ia--c-jI---------m ./text.txt
-uS-ia--c-jI---------m ./text_txt.swp
MarvAmBass commented 7 months ago

ahh so your system is a docker for mac system, right?

MarvAmBass commented 7 months ago

I'm going to test your setup on my mac, we will see what's wrong, or if I run into the same issue

ChrisJBurns commented 7 months ago

ahh so your system is a docker for mac system, right?

That's correct.

I'm running Docker Desktop on my Macbook. I have a docker-compose file that sets up 1 samba container and another Ubuntu container that I'm using to access the samba share. However, I'm finding that just using smbclient on my Mac and pointing it at the samba share using my machine name (/usr/libexec/PlistBuddy -c "Print :NetBIOSName" /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist), also returns the same resuls, so you may not even need to do the Ubuntu container.

My smbclient command: smbclient //my-machine-name/home -U samba.

ChrisJBurns commented 7 months ago

Hi @MarvAmBass

Update from me, I have managed to get this to work, but I have removed the volume mounts in the docker-compose file and instead created that directory on the samba container myself manually after it starts up. I then exec into my Ubuntu container and I can now create and remove files.

So instead of:

I have changed to:

And I can create and delete files within the Ubuntu /mnt/home.

So it seems that Macbook realllyy doesn't like something, and I'm not enough of a macbook expert to see what is going on. All of the permissions across the board looked fine to me. All I did was remove the volumes: section in the docker compose file and created the folder within the container myself and it all worked.

I might try a third container to somewhat "replicate" my macbook, but make it another Ubuntu container, just so I can put that volumes: line back into the docker-compose file (as it maybe something relating to the way docker mounts the volumes) to verify it definitely is the Macbook that is causing the problem.

Let me know what your investigations find, this is one of those mysteries that have really stumped me over the last couple of days and I'd really like to find out what it is about MacOS (or maybe even the way mine is configured) that doesn't allow this to work.

MarvAmBass commented 7 months ago

yeah I also needed some time to get the docker compose to work, and my ubuntu to mount the share of the samba container.

at the end I was able to mount it, but the permissions were different from the permissions my mac system. changing owner was successful but the chmod didn't fully map into the container.

But I wasn't even able to create a file on the samba share. Samba connections to a linux system running my container had no issues.

---
version: "3.3"

services:
  samba:
    image: docker.io/servercontainers/samba:latest
    container_name: samba
    restart: unless-stopped
    environment:
      ACCOUNT_myuser: test
      UID_myuser: 1000
      SAMBA_VOLUME_CONFIG_shared_home: |
        [home];
        path=/shares/home
        valid users = myuser
        browsable = yes
        writeable = yes
    volumes:
      - ./home:/shares/home

  myubuntu:
    image: ubuntu
    privileged: true
    container_name: ubuntu
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    build:
      dockerfile: Dockerfile
      context: .

I entered the ubuntu container and mounted the share using: mount.cifs //samba/home /mnt/home -o user=myuser,uid=1000,gid=1000

You have to keep in mind that Docker Desktop ist a very hacky solution for macOS and Windows - it runs some kind of virtual machine under the hood and mounts different ports, filesystem mounts etc. from and to the vm and inside the containers.

I'll stop the investigation at this point. I don't see a reason to use macos as a host system - they alread ship samba.

ChrisJBurns commented 7 months ago

Yep no problems, thanks @MarvAmBass

I have also been able to connect to the single Samba container that is sharing the local /shares/home directory via running smbclient locally in a terminal on my mac. I was always able to ls files before and create new directories, but now I can do both. So it really does seem like the volume mounting of a directory that lives on a MacOS, into the samba container really doesn't go down well. A colleague of mine thinks it's something to do with the docker volume shim for MacOS. Perhaps a note in the docs for folks who may want to try a similar setup as me?

My setup by the way wasn't to host a long-term share, but instead write a Java / Spring application that reads/writes files to an SMB share, and we needed to be able to stand up a local samba share to do some local testing of the code. In our case, we will just roll a custom image that creates that /shares/home directory in order to save us from having do it manually all of the time.

Thanks again :+1:

MarvAmBass commented 7 months ago

I added this issue to my TROUBLESHOOTING.md file. maybe it's helpful for others.

petrmatula190 commented 3 months ago

Hi averyone. I spend some time with this issue and now I can confirm the same problem on linux.

petrm@pc8:~$ uname -a
Linux pc8 6.5.0-1025-oem #26-Ubuntu SMP PREEMPT_DYNAMIC Tue Jun 18 12:35:22 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
petrm@pc8:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.4 LTS
Release:    22.04
Codename:   jammy
samba:
    image: ghcr.io/servercontainers/samba:latest
    container_name: samba
    restart: always
    environment:    
      ACCOUNT_data: "data:1000:****"
      UID_data: 1000 
      SAMBA_VOLUME_CONFIG_data: "[data]; path=/shares/data; valid users = data; browsable = yes; writable = yes; read only = no; public = no; guest ok = no" 
    volumes:
      - ./data:/shares/data
      - /etc/localtime:/etc/localtime:ro 
    ports:
      - 0.0.0.0:137:137
      - 0.0.0.0:138:138
      - 0.0.0.0:139:139
      - 0.0.0.0:445:445
    cap_add:
      - CAP_NET_ADMIN
petrm@pc8:~/docker/test$ docker context ls
NAME            DESCRIPTION                               DOCKER ENDPOINT                                  ERROR
default *       Current DOCKER_HOST based configuration   unix:///var/run/docker.sock                      
desktop-linux   Docker Desktop                            unix:///home/petrm/.docker/desktop/docker.sock   

petrm@pc8:~$ smbclient //10.10.10.8/data -U data%password
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Thu Jul 18 13:35:44 2024
  ..                                  D        0  Thu Jul 18 13:35:44 2024
  Smycky                              D        0  Fri Jul 21 11:17:14 2023
  .system                            DH        0  Tue Jul  9 13:56:16 2024
  Video                               D        0  Thu Jul 18 12:57:03 2024
  Audio                               D        0  Tue Jul  9 16:33:11 2024
  Gallery                             D        0  Fri Jun 28 15:09:48 2024

        487861248 blocks of size 1024. 81144756 blocks available
smb: \> mkdir test
smb: \> ls
  .                                   D        0  Thu Jul 18 13:35:48 2024
  ..                                  D        0  Thu Jul 18 13:35:48 2024
  Smycky                              D        0  Fri Jul 21 11:17:14 2023
  .system                            DH        0  Tue Jul  9 13:56:16 2024
  Video                               D        0  Thu Jul 18 12:57:03 2024
  Audio                               D        0  Tue Jul  9 16:33:11 2024
  Gallery                             D        0  Fri Jun 28 15:09:48 2024
  test                                D        0  Thu Jul 18 13:35:48 2024

        487861248 blocks of size 1024. 81144756 blocks available
smb: \> rmdir test
smb: \> ls
  .                                   D        0  Thu Jul 18 13:35:57 2024
  ..                                  D        0  Thu Jul 18 13:35:57 2024
  Smycky                              D        0  Fri Jul 21 11:17:14 2023
  .system                            DH        0  Tue Jul  9 13:56:16 2024
  Video                               D        0  Thu Jul 18 12:57:03 2024
  Audio                               D        0  Tue Jul  9 16:33:11 2024
  Gallery                             D        0  Fri Jun 28 15:09:48 2024

        487861248 blocks of size 1024. 81144756 blocks available
smb: \> 

After switch to docker-dektop with the same compose file

petrm@pc8:~/docker/test$ docker context ls
NAME              DESCRIPTION                               DOCKER ENDPOINT                                  ERROR
default           Current DOCKER_HOST based configuration   unix:///var/run/docker.sock                      
desktop-linux *   Docker Desktop                            unix:///home/petrm/.docker/desktop/docker.sock   

petrm@pc8:~$ smbclient //10.10.10.8/data -U data%pass
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Thu Jul 18 13:35:57 2024
  ..                                  D        0  Thu Jul 18 13:35:57 2024
  Smycky                              D        0  Fri Jul 21 11:17:14 2023
  .system                            DH        0  Tue Jul  9 13:56:16 2024
  Video                               D        0  Thu Jul 18 12:57:03 2024
  Audio                               D        0  Tue Jul  9 16:33:11 2024
  Gallery                             D        0  Fri Jun 28 15:09:48 2024

        487861248 blocks of size 1024. 81126896 blocks available
smb: \> mkdir test
NT_STATUS_ACCESS_DENIED making remote directory \test
smb: \> 

If I found some solution, I will share it there. I will need it in future for some my customers solutions. Now, Please @MarvAmBass update TROUBLESHOOTING.md file.

MarvAmBass commented 3 months ago

does the user data (id: 1000) have permissions to write to ./data?

petrmatula190 commented 3 months ago

Yes, UID is the same as OS. The folder is managed by another my docker service with apache2 + i make chmod -R 775 /path/data

So

petrm@pc8:~/docker/test$ ls -al data
celkem 0
drwxrwxr-x 1 petrm www-data  60 čec 18 13:35 .
drwxrwxr-x 1 petrm petrm    332 čec 18 13:46 ..
drwxrwxr-x 1 petrm www-data 174 čec  9 16:33 Audio
drwxrwxr-x 1 petrm www-data 112 čen 28 15:09 Gallery
drwxrwxr-x 1 petrm www-data  62 čec 21  2023 Smycky
drwxrwxr-x 1 petrm www-data 204 čec  9 13:56 .system
drwxrwxr-x 1 petrm www-data 918 čec 18 12:57 Video
petrm@pc8:~/docker/test$ stat --format '%a'  data
775
petrm@pc8:~/docker/test$ ls -al
celkem 1200552
drwxrwxr-x 1 petrm            petrm                   332 čec 18 13:46  .
drwxrwxr-x 1 petrm            petrm                   296 kvě 22 10:53  ..
drwxrwxr-x 1 petrm            www-data                 60 čec 18 13:35  data

petrm@pc8:~/docker/test$ stat --format '%a'  data/Video/BigBuckBunny.mp4 
775
petrm@pc8:~/docker/test$ ls -al data/Video/BigBuckBunny.mp4
-rwxrwxr-x 1 petrm www-data 158008374 led  7  2020 data/Video/BigBuckBunny.mp4

petrm@pc8:~/docker/test$ cat /etc/group
...
www-data:x:33:
...
petrm:x:1000:

I will try enable debug in docker desktop ;-)

EDIT: Noo, sorry i have not subsribed to docker Pro :(

MarvAmBass commented 3 months ago

okay that seems like it should work...

petrmatula190 commented 3 months ago

Hmm, I googling some time, problem is in virtualization solution and something with permissions. I found partial solution, but it is ungly fo everyone.

After create group with UID 100999, create folder/files works, but when i try delete, still getting NT_STATUS_NOT_SUPPORTED.

EDIT: same situation, if i run samba container in privileged mode.

MarvAmBass commented 3 months ago

I'm not sure If I understand - I thought you're using ubuntu as a host - but I do get, that as soon as you play around with shared filesystems you might run into problems due to mapping problems of uid etc.

petrmatula190 commented 3 months ago

I'll be more specific. Yes, I use ubuntu as host + classic docker + docker dekstop for my comfort when debuging (switch docker context is annoying and tedious). But, i am not sure, if you know, docker dekstop for linux runs in VM. This docker container is for customers whitch use Windows on your desktops and server side run on linux (on proxmox sometimes). Samba is native way to upload files from windows PC to server with dockerized aplications.

MarvAmBass commented 3 months ago

ahhh I think that's the problem - with the extra vm it messes up your mapping from local machine into the container. this is also what's an issue when you use the container from a macos.

petrmatula190 commented 3 months ago

Nice, that not the same problem. Docker desktop for linux run on VM, but for macOS runs almost natively, but only use use VirtioFS. Finally, this make this issue with samba share and mapping permissions. I found some issue on docker-dektop github.

petrmatula190 commented 3 months ago

Nice and good day. Finally i identify root of problem. Docker desktop on Linux/macOS (in some cases in Windows if use VM or WLS2 installation option). Docker desktop use different UID and GID mapping than default docker and runs in its own namespace. Docker desktop starts mapping UID and GID in host OS from 100000 (root with UID/GID 0 in docker cointainer mapped to UID/GID 100000 in host OS). In default desktop UID/GUID is the same.

I had my app in docker container and i need change file permission and files/folders owner (for generate video thumbmails). My bash script run with supervisord under root user. ./data is docker shared volume for my app and samba too.

    volumes:
        - ./mywwwapp:/var/www/html
        - ./data:/var/www/html/data

I tested on: Docker Desktop 4.32.0 (157355) Docker version 27.1.0, build 6312585 #Docker engine = default context

Problem commands:

CHOWN_USER_UID=1000
APACHE_RUN_GROUP=33
CHMOD_DATA_DIR_PERMISSIONS=0775
ECHO_PREFIX="["$(basename "$0")"]: "

#thumbnail_dir example is: /var/www/html/data/Video/.thumbnails
if ! output=$(chown $CHOWN_USER_UID:$APACHE_RUN_GROUP "$thumbnail_dir" 2>&1); then
        echo $ECHO_PREFIX"line $LINENO - $output" #LINE 34
fi

if ! output=$(chmod -R $CHMOD_DATA_DIR_PERMISSIONS "$thumbnail_dir" 2>&1); then
        echo $ECHO_PREFIX"line $LINENO - $output" #LINE 38
fi

#thumbnail_path example is: /var/www/html/data/Video/.thumbnails/VolkswagenGTIReview.png
if ! output=$(chown $CHOWN_USER_UID:$APACHE_RUN_GROUP "$thumbnail_path" 2>&1); then
        echo $ECHO_PREFIX"line $LINENO - $output" #LINE 56
fi

if ! output=$(chmod -R $CHMOD_DATA_DIR_PERMISSIONS "$thumbnail_path" 2>&1); then
        echo $ECHO_PREFIX"line $LINENO - $output" #LINE 60
fi 

This code generated errrors below only in docker desktop. In default docker works like a charm :-)

2024-07-23 10:21:46 [thumbnails_generate.sh]: Thumbnail created: /var/www/html/data/Video/.thumbnails/TearsOfSteel.png
2024-07-23 10:21:46 [thumbnails_generate.sh]: line 34 - chown: changing ownership of '/var/www/html/data/Video/.thumbnails': Operation not permitted
2024-07-23 10:21:46 [thumbnails_generate.sh]: line 38 - chmod: changing permissions of '/var/www/html/data/Video/.thumbnails/LoRaWAN_Flenexa.png': Operation not permitted
2024-07-23 10:21:46 [thumbnails_generate.sh]: line 56 - chown: changing ownership of '/var/www/html/data/Video/.thumbnails/VolkswagenGTIReview.png': Operation not permitted

So, I use chown/chmod check in my script and this indicate situation, that my cointainer run in docker desktop :-) I cannot find better check.

Second problem in my case is use inotifywait in my script. If my cointainer ruuns in docker desktop, inotifywait not catch DELETE event. In default desktop works without problem. inotifywait -q -e create -e modify -e move -e moved_to -e moved_from -e move_self -e delete_self -e delete -r /var/www/html/data

I found lot of information about daemon.json settings "userns-remap": "default", but this not work for me (docker desktop not suport it and not start if add this option)

Finally, this is all reasons why I will stop use docker desktop and why Your samba container not work correctly under docker desktop (in Linux/macOS, maybe in Windows too). Second problem in your case is samba own, smb maps permissions too, so this generate one more layer of problem.

I mean, than problem can be close, because this cannot be fixed in this repo :-)

MarvAmBass commented 3 months ago

@petrmatula190 thanks, I'll add this info into the troubleshooting markdown file and maybe notice docker desktop problems in the readme!