Alsa | Alsa dbus | Pulseaudio | Pulseaudio dbus |
---|---|---|---|
Spotifyd within a docker container for ARM (armv7/arm64) and x32/x64 architectures in configuration variants alsa/pulseaudio for audio-backend and with/without D-Bus API for controlling spotifyd through generic media players.
According to my subjective experience and available hardware, dbus in the alsa variant is better as it uses a software controller which appears to increase volume linearly. On the other hand the volume control with pure alsa renders anything below 60% practically unhearable and anything above 80% too loud. I haven't tested the pulseaudio version yet. Let me know if you have some feedback.
docker run -d --net host --group-add $(getent group audio | cut -d: -f3) --device /dev/snd:/dev/snd -v /usr/share/alsa:/usr/share/alsa -v $PWD/contrib/spotifyd.conf:/etc/spotifyd.conf hvalev/spotifyd-XXX
where you need to replace XXX
with the appropriate image tag in https://hub.docker.com/u/hvalev
.
or with docker-compose:
services:
spotifyd:
container_name: spotify
restart: always
image: hvalev/spotifyd-XXX
network_mode: host
devices:
- /dev/snd:/dev/snd
volumes:
- /usr/share/alsa:/usr/share/alsa
- /etc/spotifyd/spotifyd.conf:/etc/spotifyd.conf
- /etc/asound.conf:/etc/asound.conf
group_add:
- ${AUDIO_GRP}
If you're running this on a raspberry-pi, you can replace ${AUDIO_GRP} with 29 as that is the id of the audiogroup user. If not, simply type id
in the terminal and enter whatever number shows next to (audio).
services:
spotify:
container_name: spotify
restart: always
image: hvalev/spotifyd-pulseaudio
user: ${PUID}:${PGID}
#network_mode: host #disabling to only show logged in user in spotify app (if you run multiple containers at once with different user logins)
devices:
- /dev/snd:/dev/snd
group_add:
- ${AUDIO_GRP}
environment:
- PULSE_SERVER=unix:/tmp/pulseaudio.socket
- PULSE_COOKIE=/tmp/pulseaudio.cookie
volumes:
- /run/user/1000/pulse/native:/tmp/pulseaudio.socket
- ${USERDIR}/docker/spotifyd/spotifyd.conf:/etc/spotifyd.conf
Grab the dockerfile with the configuration you wish to build and remove --platform=$BUILDPLATFORM
from the first image. Since a single Dockerfile is used for all images, you also need to add --target alsa-dbus-release
or another flavor to build along with your build command.
At the moment the rust-fix intermediary build image exists as a workaround to this bug.
Spotifyd requires a Spotify Premium account.
Naturally, all credit goes to spotifyd. The instructions, dockerfile and explanation at GnaphronG/docker-spotifyd constitute a major portion of the contents in this repository.