-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot stream from inside a docker container without network_mode: "host"
#2559
Comments
I have very similar setup for Home Assistant (i.e., Home Assistant within docker network, with an Avahi reflector to reflect mDNS messages on the host), and I have applied some hacking to make it work. I don't think you can actually bind to host IP within the docker network, but you can map the ports used by RAOP (i.e., timing port and control port) to the container. So, on the high-level you have to do the following patching: (1) By default, pyatv uses random ports for RAOP (and the Home Assistant doesn't change them), so you have to specify fixed ports for them here: Lines 121 to 131 in 49bd01d
Let's say we fix them to 12345 and 12346 for timing and control ports. Then map the UDP ports in the docker configurations (I'm using docker compose, but passing args to plain docker command should also work) ports:
- 10.20.0.3:12345:12345/udp
- 10.20.0.3:12346:12346/udp (2) The announced RTSP uri bakes in the local address, which would be the docker internal one. We have to patch it to use the host IP here: Lines 92 to 95 in 49bd01d
Replace Then it works :) To make this more general, for (1) we don't have to change anything in pyatv, we just need to expose these options in the options flow in Home Assistant integration, for (2) we first need to make that configurable in pyatv (perhaps via another field in The HomeKit integration in Home Assistant already supports such configurations ( |
Describe the bug
When trying to stream to either an AppleTV or a HomePod mini, it fails with
RTSP/1.0 method SETUP failed with code 400: Bad Request
The RTSP stream binds to the docker network IP, not the host IP. Specifying an
--address HOST_IP
doesn't change the RTSP IP used.Running it directly on the host works.
Error log
How to reproduce the bug?
Run
atvremote --id XXXXXXX stream_file=http://XXXXXXX:8123/api/tts_proxy/XXXXXXX_en_-_google_translate.mp3
from a docker container without usingnetwork_mode: "host"
.What is expected behavior?
A
--host-ip
and-host-port
(I've seen it defaults to 5353) arguments should be introduced to be used for the RTSP stream.Operating System
Docker
Python
3.12
pyatv
0.15.1
Device
Apple TV 4K (gen 2), tvOS 18.1 and HomePod Mini, tvOS 18.1
Additional context
In the Apple Home app settings, "Speakers & TV" is set to "Everyone".
Running pyatv directly on the host works.
I use an Avahi repeater to get mDNS messages to and from the docker network
The text was updated successfully, but these errors were encountered: