I created the following script in cmd file :
docker exec my-container bash -c "stat -c '%U' /my/directory"
I have the following result :
U
But if I do the same in the command line directly, I have this :
root
If I replace U by A (to have rights instead ownership) :
docker exec my-container bash -c "stat -c '%A' /my/directory"
I have that with the command line :
drwxrwxrwx
And that with the cmd script
A
I don't understand why. For instance, I don't have any trouble with the following commands :
docker exec my-container bash -c "ls -al /"
docker exec my-container bash -c "su - -c 'ls -al /' myUser"
I have the expected result with the script and the command line.