Run multiple SPS-AP2 instances in Docker #1374
Replies: 5 comments 14 replies
-
I got pulseaudio working on my host as a system wide systemd service and the docker containers are configured to reach the host via unix:/var/run/pulse/native. I managed to spin up two instances, both pointed at the same PA sink. I have fairly good sync when testing with a set of headphones. Now I have to remember how to add sinks to PA. I will write this whole process up and share my docker-compose.yaml once I have it all nailed down. |
Beta Was this translation helpful? Give feedback.
-
So I have this working with two cards in a test server that is freshly loaded with Debian Bullseye. I have PulseAudio running as a system wide systemd service and for whatever reason on a reboot it doesn't properly add all my ALSA sinks. All I have to do is restart the pulseaudio service and they all show up. My work around is to create a bash script that checks to see if all the sinks are there and if not it restarts the service. I then have a docker compose for each shairport-sync instance. It's working really well, sync is perfect. I tested with the left headphone of one instance and the right headphone from the other instance. So the basic steps are:
And here is a sample docker-compose.yaml that will automatically create the macvlan network (I named it spsnet): services:
shairport-sync:
container_name: SPS-Livingroom
image: shairport-sync:unstable-development
restart: unless-stopped
volumes:
- ./shairport-sync.conf:/etc/shairport-sync.conf
- /var/run/pulse:/var/run/pulse
environment:
- PULSE_SERVER=unix:/var/run/pulse/native
- PULSE_COOKIE=/tmp/pulseaudio.cookie
networks:
spsnet:
ipv4_address: 192.168.1.100 # Static IP assign to the container. Make sure it's not already in use on the host network
networks:
spsnet:
name: spsnet
driver: macvlan
driver_opts:
parent: eno1 # Physical network interface on host that we want to bind to
ipam:
config:
- subnet: 192.168.1.0/24 # This needs to match the subnet of your host network
gateway: 192.168.1.254 I will write up something more formal and create a GitHub repo with the README.md and the pulseaudio.service I am using. I really wish I could figure out why PulseAudio fails to pickup my ALSA sinks on a reboot without restarting the service. That is the one thing that convoluts the whole thing. It would also be nice if the container could pull an IP from DHCP but I was unable to find a way to do that, |
Beta Was this translation helpful? Give feedback.
-
I finally got around to making more legit instructions and packaged it all up here: |
Beta Was this translation helpful? Give feedback.
-
That's funny, I was literally working on announcement with ALSA when you wrote your reply. |
Beta Was this translation helpful? Give feedback.
-
I have a setup running 9 instances of shairport-sync outputting across two USB sound cards on an armbian host. The shairport-sync package in armbian is quite old so I started migrating the setup over to
If I
So it seems like these containers are getting stuck on starting dbus. Any clues as to why? |
Beta Was this translation helpful? Give feedback.
-
So I just discovered a way to run multiple instances of SPS-AP2 in Docker containers that each have their own IP on the host network.
First you need to create a new Docker network like this:
In the above command, you eno1 is the physical network interface on your host machine. The subnet and gateway need to match your host networks subnet and gateway. I am naming this network spsnet.
Now when you run the first instance of shairport-sync, do it like this:
And the second instance like this:
You can see I am also mapping in a custom shairport-sync.conf into each container. I have also specified a static IP for each container. You would need to make sure these statics aren't already in use on your network.
The only hang up I am having is with my elaborate alsa config. My asound.conf busts a single 7.1 card into multiple cards. It works fine on the host but for some reason the containers complain that the card is in use. I can connect and play to the FirstInstance and sound comes out of the correct output. I can then disconnect from the FirstInstance and then connect and play to the SeccondInstance and the audio comes out of the other output. I just can't play to both instances at the same time because SPS complained that the output is busy. ALSA dmix just doesn't seem to work correctly in Docker containers.
It looks like the only way for this to really work would be having fully discrete sound cards for each instance and let each instance have exclusive access to each card. I'm amazed there isn't more talk about ALSA and dmix in Docker. Seems the whole world uses Pulse for everything these days.
mikebrady/shairport-sync:unstable-development doesn't have Pulse support so I'll have to make my own image but I suspect I can get it to work with Pulse. I feel like I am close to having a super easy to deploy way of running multiple SPS-AP2 instances without a stack of Raspberry Pi's.
Beta Was this translation helpful? Give feedback.
All reactions