Hiya,
New to the community (first post), but not new to docker or HA. Sorry to revive a dead topic, but thought it might be useful to OP or others viewing. I basically expanded on this excellent guide and added Zigbee support.
With the following docker-compose.yml
file, I was able to get NR and HA to play nice with one another. The important parts here are:
- Set the network mode to
host
for both. HA needs to use the native VM’s (or server’s) network in order to see other devices on the network, lest you want to do some really painful networking.
- Reference config volumes for both that are persistent. In my case, they were both directories on my NAS that the host docker VM is able to access.
# Works as of 2022-08-20
version: '3'
services:
homeassistant:
container_name: homeassistant
devices:
- /dev/ttyACM0 # This is a reference to the Conbee II Zigbee hub
# that I mapped to this VM from Proxmox. Omit if you
# don't have it. You don't need DeConZ anymore.
# Your device ID may be different.
environment:
- TZ=America/New_York # Replace with your timezone in the same format.
# This is the GitHub package that they recommend using in HA's Getting
# Started page, but the one on Docker seems to be updated in parallel.
image: "ghcr.io/home-assistant/home-assistant:stable"
network_mode: host # CRITICAL!
privileged: true
restart: unless-stopped
volumes:
# Replace the first part of this with the actual path
# to your persistent config.
- /path/to/your/persistent/ha/config:/config
- /etc/localtime:/etc/localtime:ro
node-red:
container_name: "node-red"
# Only include this 'build' line if you're building your own NR image
# (e.g. with add-on flows) as per Jordan Rounds' guide. Mine is in a
# subdirectory called "node_red" but you can place the Dockerfile in the
# same dir if you want. Just replace './node_red' with '.'.
build: ./node_red
environment:
- TZ=America/New_York # Replace with your timezone in the same format.
network_mode: host # CRITICAL!
image: "nodered/node-red" # Optionial if you're building.
restart: unless-stopped
ports:
- "1880:1880"
volumes:
# Replace the first part of this with the actual path
# to your persistent config.
- /path/to/your/persistent/ha/config:/data
Hope this helps someone.
JD
EDIT: Forgot to mention updating.
Updating both is a cinch, and so long as your config is stored outside of docker, it shouldn’t break anything (regular backups are still recommended).
This is the script I use to update my images:
cd /path/to/your/docker-compose.yml # change as appropriate
sudo docker-compose pull # updates the images / builds as necessary
sudo docker-compose up -d --remove-orphans # deploys the updates in the background, removes the old ones
sudo docker image prune -f # deletes old images to save space