invoiceninja / dockerfiles

Docker files for Invoice Ninja
https://hub.docker.com/r/invoiceninja/invoiceninja
GNU General Public License v2.0
413 stars 267 forks source link

Container startup only works with bind mount; `cp: can't create directory '/var/www/app/storage/app': Permission denied` #558

Open ToshY opened 10 months ago

ToshY commented 10 months ago

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:

  1. Use fresh docker-compose.yml (or something similar)
  2. 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
  1. Up the services.
  2. 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.

image

Expected behavior

Able to use volumes instead of bind mounts.

Docker:

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`
ryangurn commented 9 months ago

Possible duplicate items #330, #289, #194

Helpful Links:

ToshY commented 9 months ago

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.

ryangurn commented 9 months ago

@ToshY i think that recommendation was updated and put the in read me... might want to check that.

litecactus commented 7 months ago

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
javydreamercsw commented 5 months ago

Just tried today after finding this for the first time and ran into this. Nothing suggested seems to work.