Container startup only works with bind mount; `cp: can't create directory '/var/www/app/storage/app': Permission denied`
Setup information
docker compose v2.24.0
Describe the bug
It's not possible to setup the application using docker volumes with the example config provided, as it throws the following error in the container logging:
invoiceninja-1 | 2024-01-17T17:48:47.208852859Z cp: can't create directory '/var/www/app/storage/app': Permission denied
invoiceninja-1 | 2024-01-17T17:48:48.206288663Z cp: can't create directory '/var/www/app/storage/app': Permission denied
invoiceninja-1 exited with code 1
This is similar to #330 , but because I'm not using bind mount but volumes I cannot perform chmod / chown operations, as the volumes are manager by docker.
To reproduce Steps to reproduce the behavior:
- Use fresh
docker-compose.yml(or something similar) - For the app service change the following volumes.
from
services:
app:
volumes:
- ./docker/app/public:/var/www/app/public:rw,delegated
- ./docker/app/storage:/var/www/app/storage:rw,delegated
to
services:
app:
volumes:
- app_public:/var/www/app/public:rw,delegated
- app_storage:/var/www/app/storage:rw,delegated
volumes:
app_public:
driver: local
app_storage:
driver: local
- Up the services.
- Check logging of app container throwing the error.
Also tried using user: root and user: 1500 on app service, which both result in similar error in UI.
Expected behavior
Able to use volumes instead of bind mounts.
Docker:
- Output of
docker version:
Client: Docker Engine - Community
Version: 24.0.5
API version: 1.43
Go version: go1.20.6
Git commit: ced0996
Built: Fri Jul 21 20:35:18 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 24.0.5
API version: 1.43 (minimum version 1.12)
Go version: go1.20.6
Git commit: a61e2b4
Built: Fri Jul 21 20:35:18 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.22
GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca
runc:
Version: 1.1.8
GitCommit: v1.1.8-0-g82f18fe
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Additional context
invoiceninja/invoiceninja: 5.8.10
Possible duplicate items #330, #289, #194
Helpful Links:
- https://github.com/invoiceninja/dockerfiles/issues/289#issuecomment-784919578
- https://github.com/invoiceninja/dockerfiles/issues/194#issuecomment-679139671
- https://github.com/invoiceninja/dockerfiles/issues/330#issuecomment-962215009
Possible duplicate items #330, #289, #194
Helpful Links:
Yes this is most likely related to #194 , however I'm not convinced that manually chowning the volume in /var/lib/docker directory is an appropriate solution.
@ToshY i think that recommendation was updated and put the in read me... might want to check that.
running docker in rootless mode I still get this error even after the additional permission step as suggested. My UID is 1000 so I also tried that (assuming that that is what the 1500 is?)
chmod 755 docker/app/public
sudo chown -R 1500:1500 docker/app
Just tried today after finding this for the first time and ran into this. Nothing suggested seems to work.