Not a docker expert (although I’m using it for HA too), but it seems as if you’ve specified a network (“hass-net”) which I think creates a seperate network just for that container. Try removing it and see if it works.
also you need to remove the “-p 8123:8123” part. You can’t have net=host and specify a port since net=host opens all the host ports to the container.
As others have mentioned, you have several problems with your run.
get rid of --network=hass-net
, and -p 8123:8123
and everything should work fine.
Yes, that was correct. Removing the two entrees and adding --network=host did allow for Home Assistant discovery but I lost the ability for containers to reference each other by container name via the internal Docker DNS.
After looking around the web I found that using a network driver type of MACVLAN worked. I created a docker MACVLAN network hass-macvlan and assigned a container NIC to that network with a static local network IP. I then was able to assign the --network=hass-net to the same container.
--network=hass-macvlan \
--ip=192.168.250.220 \
Now I have access to Home Assistant web interface on IP 192.168.250.220 and the Docker internal network hass-net 172.20.10.1/24 for inter container communications.
Note:
Portainer 1.19 will not use MACVLAN on non-swarm containers.
You need to use 1.20dev
portainer/portainer:fix2412-macvlan-not-listed
Do I understand it correctly? Following these instructions, I can put HA docker (non-Hass.io) into docker’s subnet and still have ability to use discovery and communicate between devices which are outside of subnet in the same phisical LAN?
If Yes, can someone rewrite above instructions for a newbie step-by-step instruction?
I tried playing around with this, and once I start the container in net=host mode, I can’t get the UI up.
Hi,
I have used this command to install docker hass.io: hassio-build/install at master · home-assistant/hassio-build · GitHub on Raspian (RPi #B+) but now I have trouble with discovering Xiaomi Mi Box (and probably issue with Xiaomi Vacuum). After reading this troubleshooting: Removed integration - Home Assistant I came to the conclusion that I need to add “–net=host” added to the docker run.
How to do that after the setup of HA? If I will do that will I lose current instance/configuration of hass.io?
My “docker ps”:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4t8guiefsfwd homeassistant/raspberrypi3-homeassistant "/bin/entry.sh pytho…" 23 hours ago Up About an hour homeassistant
fdecefrfewdw homeassistant/armhf-addon-duckdns "/run.sh" 23 hours ago Up 23 hours addon_core_duckdns
5hny5ij4g3rr homeassistant/armhf-hassio-supervisor "python3 -m hassio" 2 days ago Up 23 hours hassio_supervisor
Thanks for any help,
Viv
When you install hassio that parameter is already set.
Thanks.
I was able to discover Xiaomi Mi Box after some iptables tweaking and the Xiaomi Vacuum had different token then before.
I tried creating a home assistant install via a docker image, but if I use the
--ip=192.168.x.x
parameter, I get the following error:
docker: invalid reference format.
I hadn’t looked at this in a long time, but as best I can tell, the --net=host option for docker on MacOS doesn’t work and using the -p 8123:8123 option doesn’t allow discovery to work.
I gave up, ubuntu got me up and running. Update in case future folks find this thread
I wish I could find the original source of the solution to give credit, but…
If you want to run home assistant in a docker container without --net=host or even in a swarm and maintain the discovery functionality the solution is do the following on the host(s).
- Edit /etc/avahi/avahi-daemon.conf to have the following
[reflector]
enable-reflector=yes
reflect-ipv=no
- sudo systemctl restart avahi-daemon
- repeat for all nodes in swarm, if applicable
Edit: Found the source all credits go here.
Just to confirm, Docker Desktop for OSX simply does not support --net=host (generally, not just for HA), or the macvlan network mode. This means HA on Docker on Mac is impossible to use, as discovery is broken with port mapping (-p), and docs for manual configuration of all your integrations are lacking.
Thank for the info.
I confirm this “avahi-daemon” setup makes my home Assistant in a docker with bridge network (and swag proxy) discovering my google cast devices
Using Portainer to manage my containers, --net=host, how can I specify that?
If I open the container Homeassistant, all th way down, I see that I’am connected to Host network
If this the same as stateing --net=host in startup?
Sorry, quite a newbie on hassio/docker
I second this. After spending the last week stuffing around trying to get everything to work, this little gem solved the issue.
I just want to add to this conversation in case anyone is using docker desktop for mac and running into host networking issues. I switched to Rancher Desktop for mac (not using Kubernetes and selecting Moby for the engine) and added the host network in the compose file. After install, in home assistant under SETTINGS/NETWOK there are now options for selecting the adapter to use, one of those is an adapter that will allow for device discovery and awareness like a host adapter. This was a totally acceptable solution for me, hopefully it will work for someone in the future.