[GH-ISSUE #292] Running librespot in a docker container #198

Closed
opened 2026-02-27 19:29:22 +03:00 by kerem · 10 comments
Owner

Originally created by @mordax7 on GitHub (Feb 23, 2019).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/292

Hello everyone,

Just wanted to ask if anyone already tried to run librespot in a docker container?
I came so far that I am able to see the device in spotify connect, but afterwards it disconnects and I cannot see it anymore, also in that time I cannot play any songs.

Here are the logs I can get over docker logs:

INFO:librespot: librespot UNKNOWN (UNKNOWN). Built on 2019-02-23. Build ID: OFG14TeI
WARN:mdns: Failed to register IPv6 receiver: Os { code: 19, kind: Other, message: "No such device" }

Here is my Dockerfile:

FROM alpine:edge

WORKDIR /data

RUN apk -U add libgcc curl cargo portaudio-dev protobuf-dev \
 && cd /root \
 && curl -LO https://github.com/librespot-org/librespot/archive/master.zip \
 && unzip master.zip \
 && cd librespot-master \
 && cargo build --jobs $(grep -c ^processor /proc/cpuinfo) --release --no-default-features \
 && mv target/release/librespot /usr/local/bin \
 && cd / \
 && apk --purge del curl cargo portaudio-dev protobuf-dev \
 && apk add llvm-libunwind \
 && rm -rf /etc/ssl /var/cache/apk/* /lib/apk/db/* /root/master.zip /root/librespot-master /root/.cargo

CMD librespot --name "$SPOTIFY_NAME" --bitrate "$SPOTIFY_BITRATE" --disable-audio-cache --enable-volume-normalisation --linear-volume --initial-volume="$SPOTIFY_VOLUME" --zeroconf-port "$SPOTIFY_PORT"

PS: I am also new into Docker, so I know this is not best practice here. I am happy for improvement suggestions.

Originally created by @mordax7 on GitHub (Feb 23, 2019). Original GitHub issue: https://github.com/librespot-org/librespot/issues/292 Hello everyone, Just wanted to ask if anyone already tried to run librespot in a docker container? I came so far that I am able to see the device in spotify connect, but afterwards it disconnects and I cannot see it anymore, also in that time I cannot play any songs. Here are the logs I can get over ```docker logs```: ``` INFO:librespot: librespot UNKNOWN (UNKNOWN). Built on 2019-02-23. Build ID: OFG14TeI WARN:mdns: Failed to register IPv6 receiver: Os { code: 19, kind: Other, message: "No such device" } ``` Here is my Dockerfile: ``` FROM alpine:edge WORKDIR /data RUN apk -U add libgcc curl cargo portaudio-dev protobuf-dev \ && cd /root \ && curl -LO https://github.com/librespot-org/librespot/archive/master.zip \ && unzip master.zip \ && cd librespot-master \ && cargo build --jobs $(grep -c ^processor /proc/cpuinfo) --release --no-default-features \ && mv target/release/librespot /usr/local/bin \ && cd / \ && apk --purge del curl cargo portaudio-dev protobuf-dev \ && apk add llvm-libunwind \ && rm -rf /etc/ssl /var/cache/apk/* /lib/apk/db/* /root/master.zip /root/librespot-master /root/.cargo CMD librespot --name "$SPOTIFY_NAME" --bitrate "$SPOTIFY_BITRATE" --disable-audio-cache --enable-volume-normalisation --linear-volume --initial-volume="$SPOTIFY_VOLUME" --zeroconf-port "$SPOTIFY_PORT" ``` *PS:* I am also new into Docker, so I know this is not best practice here. I am happy for improvement suggestions.
kerem 2026-02-27 19:29:22 +03:00
Author
Owner

@sashahilton00 commented on GitHub (Mar 11, 2019):

I suspect zeroconf in docker is going to be problematic

<!-- gh-comment-id:471694836 --> @sashahilton00 commented on GitHub (Mar 11, 2019): I suspect zeroconf in docker is going to be problematic
Author
Owner

@mordax7 commented on GitHub (Mar 11, 2019):

Zeroconf should work in docker, why?
Found out one of the ways how to do it, just mount /dev/snd and it should work. It includes the audio data sinks.

<!-- gh-comment-id:471703119 --> @mordax7 commented on GitHub (Mar 11, 2019): Zeroconf should work in docker, why? Found out one of the ways how to do it, just mount /dev/snd and it should work. It includes the audio data sinks.
Author
Owner

@sashahilton00 commented on GitHub (Mar 11, 2019):

Just based on other problems we've seen around here w/ regards to zeroconf problems, though if it works for you, great. We're not going to be giving much/any time to supporting Docker though, as there are more pressing priorities. Good luck getting it running though.

<!-- gh-comment-id:471704577 --> @sashahilton00 commented on GitHub (Mar 11, 2019): Just based on other problems we've seen around here w/ regards to zeroconf problems, though if it works for you, great. We're not going to be giving much/any time to supporting Docker though, as there are more pressing priorities. Good luck getting it running though.
Author
Owner

@mordax7 commented on GitHub (Mar 11, 2019):

I will try to find a bit more proficient way of doing it, afterwards I will release it to github and update this ticket...

<!-- gh-comment-id:471713215 --> @mordax7 commented on GitHub (Mar 11, 2019): I will try to find a bit more proficient way of doing it, afterwards I will release it to github and update this ticket...
Author
Owner

@titilambert commented on GitHub (Apr 21, 2019):

@xMordax which command do you use to launch you docker container ?

<!-- gh-comment-id:485272303 --> @titilambert commented on GitHub (Apr 21, 2019): @xMordax which command do you use to launch you docker container ?
Author
Owner

@dubo-dubon-duponey commented on GitHub (Nov 9, 2019):

I managed to have it work in a container after some tinkering.

zeroconf is not an issue in itself (granted you use the appropriate networking mode for your container - eg: host or mac/ip vlan - bridge of course will not work).

It seems that librespot will not work if there is no ipv6 though (and I couldn't find a way to disable ipv6 in librespot) (disclaimer: I'm new to librespot, apologies if I'm mistaken or otherwise missed something on that part)

So, the trick is to enable ipv6 for docker, eg: /etc/docker/daemon.json

{
        "ipv6": true,
        "fixed-cidr-v6": "2001:db8:1::/64"
}

Once done, and granted your networking is in order, librespot will properly advertise and accept input (I'm using macvlan on wired machines, and ipvlan on wifi devices - but I assume host networking would work as well if you can't be bothered to setup mac/ip vlan).

I'm still struggling to get it use an alsa card other than hw:0, but that's a different problem.

Here is a github repo with a working multi-arch image:

https://github.com/dubo-dubon-duponey/docker-librespot

Image can be pulled from the Hub as well:

https://hub.docker.com/r/dubodubonduponey/librespot/tags

I'll add detailed instructions on the networking part later on but the above should be enough to get going...

Hope that helps.

<!-- gh-comment-id:552058573 --> @dubo-dubon-duponey commented on GitHub (Nov 9, 2019): I managed to have it work in a container after some tinkering. zeroconf is not an issue in itself (granted you use the appropriate networking mode for your container - eg: host or mac/ip vlan - bridge of course will not work). It seems that librespot will not work if there is no ipv6 though (and I couldn't find a way to disable ipv6 in librespot) (disclaimer: I'm new to librespot, apologies if I'm mistaken or otherwise missed something on that part) So, the trick is to enable ipv6 for docker, eg: /etc/docker/daemon.json ``` { "ipv6": true, "fixed-cidr-v6": "2001:db8:1::/64" } ``` Once done, and granted your networking is in order, librespot will properly advertise and accept input (I'm using macvlan on wired machines, and ipvlan on wifi devices - but I assume host networking would work as well if you can't be bothered to setup mac/ip vlan). ~~I'm still struggling to get it use an alsa card other than hw:0, but that's a different problem.~~ Here is a github repo with a working multi-arch image: https://github.com/dubo-dubon-duponey/docker-librespot Image can be pulled from the Hub as well: https://hub.docker.com/r/dubodubonduponey/librespot/tags I'll add detailed instructions on the networking part later on but the above should be enough to get going... Hope that helps.
Author
Owner

@dubo-dubon-duponey commented on GitHub (Nov 9, 2019):

Seems like the requirement for ipv6 came from the mdns library being used github.com/plietar/rust-mdns@0974ab4ff7/src/lib.rs (L109)

Which is no longer true since github.com/librespot-org/librespot@d91bf573a4 landed.

@xMordax updating to librespot v0.1.0 or more recent should "fix" your problem (making it unnecessary to setup ipv6 for docker)

^ again, my understanding of librespot is limited, so, take it with a grain of salt - bottom-line though, I'm now running d91bf573a4 WITHOUT any ipv6 monkeying, on a raspberry pi.

Librespot rocks! ;-)

<!-- gh-comment-id:552076449 --> @dubo-dubon-duponey commented on GitHub (Nov 9, 2019): Seems like the requirement for ipv6 came from the mdns library being used https://github.com/plietar/rust-mdns/blob/0974ab4ff7874437e11a89037c8258362a0061f8/src/lib.rs#L109 Which is no longer true since https://github.com/librespot-org/librespot/commit/d91bf573a460045a08d3d41c5493f64ce2ee1950 landed. @xMordax updating to librespot v0.1.0 or more recent should "fix" your problem (making it unnecessary to setup ipv6 for docker) ^ again, my understanding of librespot is limited, so, take it with a grain of salt - bottom-line though, I'm now running d91bf573a460045a08d3d41c5493f64ce2ee1950 WITHOUT any ipv6 monkeying, on a raspberry pi. Librespot rocks! ;-)
Author
Owner

@ashthespy commented on GitHub (Nov 9, 2019):

Seems like the requirement for ipv6 came from the mdns library being used github.com/plietar/rust-mdns@0974ab4ff7/src/lib.rs (L109)

That's not really an error, but more the library warning you that it didn't find any ipv6 interface - it can be ignored.

<!-- gh-comment-id:552093779 --> @ashthespy commented on GitHub (Nov 9, 2019): >Seems like the requirement for ipv6 came from the mdns library being used https://github.com/plietar/rust-mdns/blob/0974ab4ff7874437e11a89037c8258362a0061f8/src/lib.rs#L109 That's not really an error, but more the library warning you that it didn't find any ipv6 interface - it can be ignored.
Author
Owner

@dubo-dubon-duponey commented on GitHub (Nov 10, 2019):

That's not really an error, but more the library warning you that it didn't find any ipv6 interface
it can be ignored.

Well, it still seems that librespot (before d91bf573a4) will not work without ipv6... so...

Either way the latest does not exhibit the same behavior, and does work (with or) without ipv6, which is great!

<!-- gh-comment-id:552153715 --> @dubo-dubon-duponey commented on GitHub (Nov 10, 2019): > That's not really an error, but more the library warning you that it didn't find any ipv6 interface > it can be ignored. Well, it still seems that librespot (before d91bf573a460045a08d3d41c5493f64ce2ee1950) will not work without ipv6... so... Either way the latest does not exhibit the same behavior, and does work (with or) without ipv6, which is great!
Author
Owner

@kingosticks commented on GitHub (Nov 10, 2019):

I have never seen that warning ever cause an actual problem. Librespot certainly has never required ipv6 to work (at least outside of the world of docker networking).

<!-- gh-comment-id:552173387 --> @kingosticks commented on GitHub (Nov 10, 2019): I have never seen that warning ever cause an actual problem. Librespot certainly has never required ipv6 to work (at least outside of the world of docker networking).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#198
No description provided.