jovandeginste / workout-tracker

A workout tracking web application for personal use (or family, friends), geared towards running and other GPX-based activities
Other
945 stars 31 forks source link

docker image as non-root user #136

Closed DavidHenryThoreau closed 5 months ago

DavidHenryThoreau commented 5 months ago

Inside the docker image the app seems to run as root user:

docker exec -it workout-tracker sh
/data # ps -ef|grep workout
    1 root      0:00 /app/workout-tracker
   20 root      0:00 grep workout

Maybe it would be great to create a user with less privileges ?

jovandeginste commented 5 months ago

You can pass the -u flag to docker run; if the volume is writable for that user, everything should work (you may need to use an unprivileged port too)

DavidHenryThoreau commented 5 months ago

For all docker compose pull && docker compose up -d app I'm using these env vars :

    environment:
      - PUID=1000
      - PGID=1000

I'm looking at -u if that fix this error. My first message was to create a workout-tracker user directly in the Dockerfile I will try this option too, if you're ok i'll do a PR.

jovandeginste commented 5 months ago

Yes that's how linuxserver build their images; I have nothing against it, but seems like an extra layer which is not per se necessary...

jovandeginste commented 5 months ago

I tested with:

docker run --rm -i -p 8080:8080 -u 1000:1000 -v $(pwd):/data workout-tracker

This seems to work, as long as $(pwd) is owned by the uid (1000).

Otherwise, you get a weird error:

failed to initialize database, got error unable to open database file: out of memory (14)