navidrome / navidrome

🎧☁️ Modern Music Server and Streamer compatible with Subsonic/Airsonic
https://www.navidrome.org
GNU General Public License v3.0
10.16k stars 783 forks source link

[Bug]: Rootless Podman Setup Throwing "attempt to write a readonly database" #2967

Open jollySleeper opened 3 weeks ago

jollySleeper commented 3 weeks ago

I confirm that:

Version

v0.51.1

Current Behavior

Hi, I have installed NaviDrome using Podman and am trying to run rootless with non-root user using the following command:

podman run \
 --restart unless-stopped \
 --label io.containers.autoupdate=registry \
 --user $(id -u):$(id -g) \
 --env-file "$HOME/navidrome/local.env" \
 -p 127.0.0.1:4533:4533 \
 -v "$HOME/navidrome/data":/data \
 -v ${HOME}/media/music:/music \
 --name "navidrome" \
 docker.io/deluan/navidrome;

But am getting the following error.

time="2024-04-22T16:47:26Z" level=error msg="Error disabling foreign_keys" error="attempt to write a readonly database"
time="2024-04-22T16:47:26Z" level=fatal msg="Database could not be opened!" error="attempt to write a readonly database"

I have seen same issues reported by other users but did not find any solution. Does Navidrome doesn't support running with Non-Root User??

PS:

Expected Behavior

Should Work

Steps To Reproduce

As Written Above

Environment

- OS: Ubuntu 24.04
- Browser: 
- Client: ?

How Navidrome is installed?

Docker

Configuration

No response

Relevant log output

No response

Anything else?

No response

Code of Conduct

deluan commented 3 weeks ago

Does Navidrome doesn't support running with Non-Root User??

Not completely sure about Podman, but for Docker: Yes it does. But you have to make sure that the /data volume is writable by the userid you choose.

If the path you choose to mount as /data does not exist when you first start the container, Docker will create it with its own permissions (usually root), and then mount it in the container. That causes Navidrome (running under the userid you choose) to not have write permissions on the /data folder (owned by root), leading to the errors you are seeing.

You can try doing this:

If it is not working with Podman after this, I can't really help you as I don't use nor have an installation of Podman, and you better off reaching out to the community in Reddit, Discord or our GH Discussions

jollySleeper commented 3 weeks ago

Yes I tried Multiple times before drafting this Issue. Even changed the ownership and gave 777 to db but just to get the same error again :(

Will try out more.

deluan commented 3 weeks ago

Try removing the $HOME/navidrome/data folder, and creating it with the correct permissions in the first place.

After doing this, I can get it running with my userid:

$ mkdir $HOME/data
$ docker run  --user $(id -u):$(id -g)  -p 127.0.0.1:4533:4533  -v "$HOME/data":/data  -v ${HOME}/music:/music  --name "navidrome" docker.io/deluan/navidrome
 _   _             _     _
| \ | |           (_)   | |
|  \| | __ ___   ___  __| |_ __ ___  _ __ ___   ___
| . ` |/ _` \ \ / / |/ _` | '__/ _ \| '_ ` _ \ / _ \
| |\  | (_| |\ V /| | (_| | | | (_) | | | | | |  __/
\_| \_/\__,_| \_/ |_|\__,_|_|  \___/|_| |_| |_|\___|
                          Version: 0.51.1 (6d253225)

time="2024-04-22T21:56:32Z" level=info msg="Creating DB Schema"
time="2024-04-22T21:56:33Z" level=info msg="Starting signaler"
time="2024-04-22T21:56:33Z" level=error msg="Agent not available. Check configuration" name=lastfm
time="2024-04-22T21:56:33Z" level=error msg="Agent not available. Check configuration" name=spotify
time="2024-04-22T21:56:33Z" level=info msg="Configuring Media Folder" name="Music Library" path=/music
time="2024-04-22T21:56:33Z" level=info msg="Creating Image cache" maxSize="100 MB" path=/data/cache/images
time="2024-04-22T21:56:33Z" level=info msg="Starting scheduler"
time="2024-04-22T21:56:33Z" level=info msg="Scheduling periodic scan" schedule="@every 1m"
time="2024-04-22T21:56:33Z" level=info msg="Running initial setup"
time="2024-04-22T21:56:33Z" level=info msg="Creating new JWT secret, used for encrypting UI sessions"
time="2024-04-22T21:56:33Z" level=info msg="Setting Session Timeout" value=24h
time="2024-04-22T21:56:33Z" level=info msg="Login rate limit set" requestLimit=5 windowLength=2
time="2024-04-22T21:56:33Z" level=info msg="Finished initializing cache" cache=Image elapsedTime=263.3ms maxSize=100MB
time="2024-04-22T21:56:34Z" level=info msg="Found ffmpeg" path=/usr/bin/ffmpeg
time="2024-04-22T21:56:34Z" level=info msg="Spotify integration is not enabled: missing ID/Secret"
time="2024-04-22T21:56:34Z" level=info msg="Mounting Native API routes" path=/api
time="2024-04-22T21:56:34Z" level=error msg="Agent not available. Check configuration" name=lastfm
time="2024-04-22T21:56:34Z" level=error msg="Agent not available. Check configuration" name=spotify
time="2024-04-22T21:56:34Z" level=info msg="Creating Transcoding cache" maxSize="100 MB" path=/data/cache/transcoding
time="2024-04-22T21:56:34Z" level=info msg="Finished initializing cache" cache=Transcoding elapsedTime="337.1µs" maxSize=100MB
time="2024-04-22T21:56:34Z" level=info msg="Mounting Subsonic API routes" path=/rest
time="2024-04-22T21:56:34Z" level=error msg="Agent not available. Check configuration" name=lastfm
time="2024-04-22T21:56:34Z" level=error msg="Agent not available. Check configuration" name=spotify
time="2024-04-22T21:56:34Z" level=info msg="Mounting Public Endpoints routes" path=/share
time="2024-04-22T21:56:34Z" level=info msg="Mounting LastFM Auth routes" path=/api/lastfm
time="2024-04-22T21:56:34Z" level=info msg="Mounting ListenBrainz Auth routes" path=/api/listenbrainz
time="2024-04-22T21:56:34Z" level=info msg="Mounting Background images routes" path=/backgrounds
time="2024-04-22T21:56:34Z" level=info msg="Mounting WebUI routes" path=/app
time="2024-04-22T21:56:34Z" level=info msg="----> Navidrome server is ready!" address="0.0.0.0:4533" startupTime=6.78s tlsEnabled=false
andrewgdunn commented 2 weeks ago

Have selinux on your system? your volume mounts should have :z or :Z appended to them if so.