Using Nut Sensor with docker without --net=host
Can’t get Nut to connect to NUT at localhost since docker has no port out to connect to host I believe.
Any using Nut with docker? How you connecting?
Any work around for this? How allow docker connect service listening on localhost port?
I did verify Nut running and data received when run command from host.
So after several hours of trying to get this integration running for me for the first time I have figured it out. I don’t know if you need a config change for NUT or Home Assistant or Docker, but below is how I have everything configured. Obviously make up your own <user> and <pass> for the config and ensure ups.conf is configured correctly for your UPS.
/etc/nut/nut.conf
MODE=netserver
/etc/nut/upsd.conf Note: probably can be restricted with a specific IP, but was just trying to eliminate barriers.
partial configuration.yaml Note: the host address below can be found by running ifconfig on the host and looking for the docker0 entry. This is the IP address of the docker host on the default bridge network.
I know this is old but I wanted to throw my own “bash-my-head-against-the-wall” experience.
I followed all of the info I could find from here first (before I found this thread):
(NOTE: you will get an error after you install the “nut” package when the service starts because there is no config yet. Just ignore it and continue on with editing the config files.)
then when I finally ran the “upsc myups” command to test it all out I kept getting a “network unreachable” error.
I then came upon this thread and edited the config files as described above (thanks @jdm12989!).
But I still got the same error and I wasn’t able to reach it via HA when setting up the integration in the HA UI either.
Then after googling the error I found this website (in Russian so you’ll need to translate) that said that they needed to restart the nut service:
By running (may need sudo, I did):
service nut-server restart
After I did that and then checked the nut service status:
service nut-server status
The result was that the service was running fine.
Then I was able to enter in the info on the integration UI (using “localhost”) and everything worked. Yay!