To start off I am new to Home Assistant and Docker. Moving from Smartthings to HASS for the control and the ability to run locally.
The environment that I am building:
i5 low power utilization, 8GB, 120GB M2 SSD
Ubuntu Server 8.04
Docker
Portainer (Docker management)
homeassistant/home-assistant
traefik (reverse proxy - Let’s Encrypt wild card cert)
eclipse-mosquitto (MQTT)
stjohnjohnson/smartthings-mqtt-bridge (access to Z-Wave – looking for a Z-Wave to MQTT bride – to run on remote Pi)
nodered/node-red-docker
The primary issue being that hass not being on the same subnet as my primary network not being able to use the built in discovery capabilities (discovery is activated in configuration.yaml). this first was noticeable when HASS did not find my Google Home Mini’s for the Google Cast functions.
When I started testing HASS I used HASS.IO (homeassistant/amd64-hassio-supervisor) on docker and it was able to conduct discovery. The HASS .IO implementation created a NIC "eno1" in its homeassistant container that is in the host network. This worked perfectly to discover items on the primary network. Unfortunately, there are other issues with the HASS .IO docker implementation and program updates and (add-on’s) that caused me to move to the mainline Home Assistant docker implementation.
I have RTFM for the discovery issue and have added --network=host to docker run but docker returns “Failure container cannot be disconnected from host network or connected to the host network”. I have also attempted to add a Google Home Mini manually into the configuration.yaml despite being able to ping it from within the container.
# Google Cast
cast:
media_player:
- host 192.168.250.168
Any help would be apricated
It would be nice if the homeassistant/home-assistant container had the "eno1"NIC the same as the HASS.IO implementation.
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.
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?
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
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 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
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.