Docker-compose- folder ownership behave differently on two machines

I have two Ubuntu server with the same Docker version (see below) same docker-compose version (see below). I deployed the same image on both machines and I run the container with the same docker-compose.yml file.

My problem is that I have different behaviour for what concerns folder ownership inside the container:

This is what I get on one machine:
drwxr-xr-x 5 root root 4096 Apr 15 13:18 myfile1
drwxr-xr-x 2 root root 4096 Apr 15 12:32 myfile2
drwxrwxr-x 2 theuser theuser 20480 Apr 15 13:13 myfile3
drwxr-xr-x 2 root root 4096 Apr 15 13:18 myfile4

But this is how I set it and how I get on the other machine:
drwxr-xr-x 5 root root 4096 Apr 15 13:18 myfile1
drwxr-xr-x 2 theuser theuser 4096 Apr 15 12:32 myfile2
drwxrwxr-x 2 theuser theuser 20480 Apr 15 13:13 myfile3
drwxr-xr-x 2 root root 4096 Apr 15 13:18 myfile4

Do you have any idea why it is so?

DOCKER VERSION
Client:
Version: 19.03.6
API version: 1.40
Go version: go1.12.17
Git commit: 369ce74a3c
Built: Wed Oct 14 19:00:27 2020
OS/Arch: linux/amd64
Experimental: false

Server:
Engine:
Version: 19.03.6
API version: 1.40 (minimum version 1.12)
Go version: go1.12.17
Git commit: 369ce74a3c
Built: Wed Oct 14 16:52:50 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.3.3-0ubuntu1~18.04.2
GitCommit:
runc:
Version: spec: 1.0.1-dev
GitCommit:
docker-init:
Version: 0.18.0
GitCommit:

DOCKER-COMPOSE
docker-compose version 1.17.1, build unknown
docker-py version: 2.5.1
CPython version: 2.7.17
OpenSSL version: OpenSSL 1.1.1g 21 Apr 2020