Compose configuration to avoid permission errors when uploading attachments

My instance of vikunjia using docker-compose throws an error (error 500) whenever I upload any attachment (avatar, background, etc). Based on the posts I have seen, this seems to be a permission issue of the files folder in the docker container. What should the compose configuration be to avoid these type of errors?

So far I have:

  api:
    image: vikunja/api
    environment:
      VIKUNJA_SERVICE_ENABLETASKATTACHMENTS: 1

logging into docker container, I see that the files is owned by root.

$ sudo docker exec -it vikunja-api-1 sh
$ ls -alh
-rwxr-xr-x    1 vikunja  root       39.2M Jan 24 17:05 vikunja
drwxr-xr-x    1 vikunja  root        4.0K Jan 24 17:06 .
drwxr-xr-x    2 root     root        4.0K Mar  1 20:43 files

Is there a way to avoid this when setting up vikunjia, other than using chown after the fact? i.e. do I need to add PUID, PGID as follows?

environment:
  VIKUNJA_SERVICE_ENABLETASKATTACHMENTS: 1
  PUID=1000
  PGID=1000

and to fix this issue, do I change ownership of the files folder to chown -R vikunja:root files? or chown -R vikunja:vikunja files?

If it really is a permission issue, there should be a message about it in the logs.

That should work.
I think in your case I’d just set the two variables and then chown -R 1000:1000 the files mount after that.

Thanks, changing the permission of the file mount to vikunja:vikunja works and now I can upload attachments.

However, I wasn’t able to change the compose file to include the PUID/PGID. I tried different ways of entering it and kept throwing me an error.

I tried:

environment:
  VIKUNJA_SERVICE_ENABLETASKATTACHMENTS: 1
  PUID=1000
  PGID=1000

and

environment:
  VIKUNJA_SERVICE_ENABLETASKATTACHMENTS: 1
    - PUID=1000
    - PGID=1000

and

environment:
  VIKUNJA_SERVICE_ENABLETASKATTACHMENTS: 1
  PUID:1000
  PGID:1000

and I kept getting: yaml: line 36: did not find expected key (line 36 is where I enter the PUID)

1 Like

Try the last config you posted but put a space between : and the numbers.

1 Like

Sorry to wake up this post, but this is the full solution for people who already have set up their Docker API instance without the PGID and PUID being in the docker-compose.yml file in the first place, just wanted to drop this here for anyone else who lands up on this page and is clueless about the error and how to solve it.

As rikrdo89 mentioned earlier, you have to get inside of your Vikunja API container and then give permission to the user vikunja to modify the files/ folder inside.

sudo docker exec -it vikunja-api-1 sh
chown -R vikunja:vikunja files/

Afterwards you should still add the PGID and PUID permissions to your docker-compose.yml if you ever rebuild completely to avoid this issue in the future, cause let’s be honest, who’s even going to remember about this one specific post in a few years down the line. This can be done by adding these environment variables at the end of the list, as kolaente mentioned, don’t forget to keep the spaces.

  PUID: 1000
  PGID: 1000

The error in the API logs
ERROR :arrow_forward: v1/UploadTaskAttachment 0e7 open files/XX: permission denied
should disappear after these changes have been made and you should be able to upload your files without issues :slight_smile:

1 Like