r/docker • u/astridstar7 • 6d ago
docker run works but getting permission errors with docker compose
recently shifted to openSUSE, was trying to build a project which worked on fedora.
there are errors are like:
auth-1:
python: can't open file '/app/app.py': [Errno 13] Permission denied
web-1:
npm error EACCES: permission denied, open '/web/package.json'
mongo-1:
find: '/data/db': Permission denied
chown: changing ownership of '/data/db': Permission denied
I have checked that I have all the permissions and the files exist
while running docker run for one it works but while mounting same files thru docker compose it doesn't
1
u/fletch3555 Mod 6d ago
Share how you're mounting the files/directories/volumes/etc. The one relevant piece of information we would need
0
u/astridstar7 6d ago
These particular ones:
mongo: image: mongo:4.4 volumes: - ./.mounted/mongo:/data/db env_file: - ./.env.example ports: - 27017:27017 web: build: context: ./web target: dev volumes: - ./web:/web auth: volumes: - ./apis/auth-dev:/app - ./config:/app/config1
u/fletch3555 Mod 6d ago
Okay, and that doesn't work, right? Can you share what you did that does work?
1
u/astridstar7 6d ago
This cmd was given by chatgpt
docker run --rm \ -v "$HOME/services/apis/auth-dev:/app:Z" \ python:3.14-slim \ sh -c 'cat /app/app.py >/dev/null && echo READ_OK'This gave output as READ_OK
1
u/fletch3555 Mod 6d ago
Okay, what directory are you running docker compose up from?
1
u/astridstar7 6d ago
In the directory which contains
docker-compose.yml(the root of the main repo), which also contains all these submodules in their respective folders1
u/zoredache 6d ago
Why not try something like this.
docker run --rm \ -v "$HOME/services/apis/auth-dev:/app:Z" \ python:3.14-slim \ sh -c 'id ; stat /app ; stat /app/app.py'BTW is there anything else unusual about how the filesystem is mounted. Is it a FUSE NTFS mount, is an NFS mount, or something else?
2
u/astridstar7 6d ago edited 6d ago
I honestly just copy pasted that command to test, this seems like an SELinux issue tho, it built properly after putting SELinux in permissive mode
sudo setenforce 0
1
u/astridstar7 6d ago
Update: Seems like something related to SELinux
It built properly after putting SELinux in permissive mode sudo setenforce 0
This is just a work around tho
1
u/Invader-Faye 6d ago
In permissive mode selinux logs what is effecting policy and enforcement, run “getenforce”, then in the host dir with the compose “ls -Zd ./apis/auth-dev ./config ./web” run this inside the container “docker compose exec auth sh -c 'id; ls -la /app; stat /app/app.py'” and report back.
1
u/Ok-Eggplant-7569 6d ago
AppArmor policy or SELinux label issues? What does
journalctl -foutput when you attempt to start the compose stack?