Tried to create a second instance of Home Assistant in docker containers in order to have a PROD (Live) and a DEV (Playground) version that I can test things in without breaking what’s live. My goal is to be able to move config files from one to the other without making any changes if possible.
I stole (copied and pasted) a docker-compose configuration that I found recently and thought for sure that it would work perfectly. But seems like the DEV container comes up but my live one can’t be reached. Not sure what I need to tweak to get this to work, I have a suspicion that ports may be the issue. Is anyone doing something similar that could advise please? Could find anything similar in the forum after some searching.
The ports should be fine since one would be accessed on 8123 and the other on 9123. I think the issue might be “sharing” the Z wave and Zigbee sticks. You would probably need separate sticks (and therefore separate mappings) for the development container.
What do the logs say though? Do you have Portainer installed? If not, I recommend getting it since you can access logs and other container information very easily.
Never thought about the USB Devices, I can surely do away with those on the DEV environment (although it would have been cool to have, not a necessity.) I do have Portainer installed but just getting acquainted with it, didn’t know that there were logs even. I can take a look and report back.
Commented the Devices (USB) in the DEV configurations and pulled a new image.
Sill no luck. If I go to IPAddress:8123, it shows me the latest version (0.72) as if this was the DEV container with nothing setup. This should show my old instance of HA with version 0.71. If I go to IPAddress:9123 it gives me an error message on the page saying “Unable to Connect”. I looked at the Portainer logs and there are no errors really, just a few warnings, nothing related to a conflict or startup of HA. Unsure if it could be related to other containers that I have in my docker-compose.
You’re using network_mode: host on both instances, which means ports: section of the config doesn’t apply. You’ll essentially have both Home Assistant instances listening on 8123. You’ll need to change the server port in configuration.yaml for one of the instances.
I’ve done the change that @NotoriousBDG suggested (Thanks) and it seems to work well. I was just hoping that I could keep all my files intact so that can promote them to the Live config directory, but if this is the only change that I need to do, I can live with that.
For others reading this thread in the future, here is what I did:
IN configuration.yaml (under http), I added:
server_port: 9123
and also change my docker-compose for home_assistant_dev (second configuration above)
ports:
- 9123:9123
Although not sure that it really does anything since it was mentioned that “network_mode: host” disregards port, but I did the change any way.
@atomicpapa - Still learning all of this, but wouldn’t be to my advantage to keep the network_mode: host so that I can leverage other containers such as MQTT that is also running as host? Not sure if I can still keep the same client_id or not. Again, still learning.
If you don’t use network_mode: host you don’t need to change the port settings in configuration.yaml, you can use any combination you like in your run command/docker compose : 9123:8123 is just as valid as 8123:8123. With host mode, the only thing that matters is the port set in configuration.yaml.
As for other containers, you can either use the built in DNS in Docker or create separate networks. Using separate networks can be an advantage if you don’t want to expose for example databases.