Permission error uploading attachment

v1/UploadTaskAttachment 3d63 open files/5: permission denied

~/vikunja$ ls -l
total 12
-rw-rw-r-- 1 rancher rancher 1022 Oct 23 16:31 docker-compose.yml
drwxr-sr-x 2 rancher rancher 4096 Oct 22 05:15 files
-rw-rw-r-- 1 rancher rancher  211 Oct 20 22:11 nginx.conf

  api:
    image: vikunja/api
    env_file:
      - .env
    volumes:
      - ./files:/app/vikunja/files
    depends_on:
      - db
      - redis
    ports:
      - 3456:3456
    restart: unless-stopped

.env file has:
VIKUNJA_SERVICE_ENABLETASKATTACHMENTS=1

Does the user you’re running vikunja as (in the container, 1000:1000 by default) have permissions to create files in the files/ folder?

1 Like

Yes, I can exec into the api container and create a file there:

vikunja$ docker exec -it vikunja_api_1 sh
/app/vikunja # cd /app/vikunja/files/
/app/vikunja/files # ls
/app/vikunja/files # touch test.txt
/app/vikunja/files # ls 
test.txt
/app/vikunja/files # 

ok, I see that the app is running as vikunja user as you mentioned.

If you do docker exec -it vikunja_api_1 sh without specifying the user, you’re probably root, not the user running Vikunja. Check that with whoami or id.

Yeah, rancher user is defaulted to 1100:1100 so most time when a none root user is used in a container to run the process, it takes the default 1000:1000 and that creates the issue. Changing the files permission to 1000:1000 solved it.

I usually pass this into container when running on rancher but with third party this isn’t set. linuxserver.io images for example uses this pattern so the process in the container runs as the user host user as specified.

PUID=1100
PGID=1100

You can actually do this with Vikunja as well: Install Backend | Vikunja

Nice. I’ll do this if I have to re-install.

Im a linux newbie

i installed vikunja following the official docker guide

once it was completed, i made my first task and went to upload an attachment

it failed.

i fixed it by running this from the cmd line

root@vikunja-sf1:/docker/vikunja# chown 1000:1000 ./files -R
:+1: