Switched to docker and now home assistant will not connect to sonos or chromecasts

I’ve gotten everything working in docker so far including the zwave hub, but home assistant cannot connect to any media players, previously on the raspberry pi it auto discovered rokus, chromecasts, and sonos no problem.

I tried adding:
media_player:

  • platform: sonos
    hosts:
    • xxx.xx.xx.xxx

You probably have to expose some ports to the container. Use network_mode: host or specify them explicitly.

Any idea which ports?
It’s already on a bridge network by default so I thought it would be able to read the ports needed.

I just tried host mode, it allowed the auto discovery to work, but doesn’t allow me to connect to other containers so it can no longer use a host for mariadb

Hi Im also running docker an have HA runing Host. It is the recommended installation procedure.

I have mqtt, mariadb, influx, etc and all connecting as required.

How do you connect the other containers? Are they also running on host?

You cannot connect to them as ‘localhost’, but you can put in the IP of the host and it will work.

I did know you could connect by the ip, but that can change, I see an option to set it though. The nice thing about the other network is the name becomes the hostname and you can use that.

I’ll try setting the ip and go from there.

Why would it change? You should never have a ‘server’ in your network with an IP that can change. Static or DHCP reservations should always be used for services.

If or when impossible, perhaps using the hostname (e.g. hassio.local) could circumvent a dynamic address.

OH, I misunderstood, I can use the ip of the server, not the ip of the container.

I was trying to be more restrictive for the server only opening the port for the vpn, but this should work too.

Only if you have a properly working DNS server in your environment. We see so many issues of crappy routers that don’t let machines resolve *.local

Is your local network not trusted?

Crappy routers also might have difficulty serving static addresses with DHCP reservations. :wink:

And that is where you set a static IP on the device itself. It doesn’t rely on a crappy router.

1 Like

Thanks for your help guys, I got it. The issue I had was I missed the advanced options in the template for mariadb. Once I saw that I could expose a consistent port on the host and connect home assistant. Also as you mentioned and I saw elsewhere home assistant has to be on the host network to do discovery.

Do you know if there is a way to get udev links to work with docker? Or is there a different way to tie the usb device to a known location. I’ve read it can occasionally change which is why I used udev on the raspberry pi.

I’ve been running my docker stack for a year and not had my USB change name.

Thanks, I’m looking at your docker stack right now and I will probably pull heavily from there.