I just happened to be sitting in front of my computer for the first time all week. LOL.
Sounds like I got lucky!
My stack is growing, Iāve gone from having 1 container running with home assistant a couple weeks ago to having 10 containers. Once Iāve got it a bit more settled Iāll share it here.
Ok, itās been a while since Iāve been in here but Iāve finally got back to it and Iāve had some major success so far.
Iāve got HA, portainer & Nginx all running perfectly.
Iāve got Syncthing running but Iām a little stuck.
I canāt seem to figure out how to expose the directory I want to sync to the syncthing web interface and then be able to share it with the other PC where I want to backup to.
my HA config files are at /home/finity/docker/hass-config.
I want to create a sync folder called hass-sync on the syncthing web server to share.
here is my docker command for running syncthing:
sudo docker create --name=syncthing -v /home/finity/docker/syncthing/config:/config -v /home/finity/docker/hass-config:/hass-sync -v /etc/localtime:/etc/localtime:ro -e PGID=1000 -e PUID=1000 -e UMASK_SET=000 -p 8384:8384 -p 22000:22000 -p 21027:21027/udp linuxserver/syncthing
when i run the docker command everything starts up fine and i can get to the web interface but all i see there is:
Where is the hass-sync folder supposed to show up? Or what am I not understanding?
By default the syncthing docker image is looking for a /sync
directory but you mounted a volume at /hass-sync
. You have 2 options. One is to mount that directory to /sync
instead, or you can create a new sync directory in syncthing web interface and point it to your /hass-sync directory.
Iāve located the directory that syncthing created @ config/hass-config.
I created a new folder in the web interface and itās shared between the machines correctly and it is updating.
The issue now is that the /config/hass-sync directory is empty. I thought that the ā-v /home/finity/docker/hass-config:/hass-syncā command essentially made those two directories the same directory - that the syncthing container would look at the /home/finity/docker/hass-config directory for the contents of the /hass-sync directory and send the host directory files over via the syncthing shared directory?
If I add a file to the /config/hass-sync directory it does get synced to the other machine correctly. So I could get it work by manually copying my config files over to the hass-config directory but that defeats the purpose of having syncthing installed.
right.
because /config/hass-sync
is a completely different directory than /hass-sync
You havenāt really accomplished anything here except creating new folders that are not volume bind mounts.
It does.
well, yes you are absolutely correct.
I changed it to /hass-sync and itās all working now.
Thanks again.
Is there a way to set up syncthing to sync a directory but exclude a specified file in that directory?
It seems like a waste to back up the log files & .dbās. the home-assistant_v2.db file can get pretty big and it is constantly changing.
cool. thanks!
I just found this thread a year and half later. Its relevant to me now, I have been using a HA in some iteration over RPI 3. The latest being hassOS, As my system grew with Zoneminder, Influx, graphana, and a variety of diy devices i donāt think my RPI is keeping up. Have been playing with Docker to get the hand of it and searched forums and found this thread its exactly what I was looking for.
Hi all. Itās me again with another question.
Iāve been using mosquitto installed and running outside of docker ever since I switched to the NUC and itās been running flawlessly.
recently Iāve had the need to get another instance of MQTT running to do some testing and I figured that using docker for it would be a great use of it.
I created all three required directories and placed a default mosquitto.conf in the config directory.
Iāve installed the image using the following run command:
$ sudo docker run -itd --name=eclipse-mosquitto -p 1884:1883 -p 9002:9001 -v /home/finity/docker/mqtt/config/mosquitto.conf:/mosquitto/config/mosquitto.conf -v /home/finity/docker/mqtt/data:/mosquitto/data -v /home/finity/docker/mqtt/log:/mosquitto/log eclipse-mosquitto
When I run the container and use MQTTFx to connect it works perfectly.
Thenā¦
When I modify the conf file to enable logging I get an error that says āunable to open the for writingā.
I added the --privileged flag to the run command and I still get the same error. the only way I can get it to go away and the container to run is if I recursively change the permissions on the mqtt directories to 777. After that everything runs fine again and the container writes to the log file and everything is good.
Then I want to add a passwordā¦
If I go into the container and run the command:
mosquitto_passwd -c /mosquitto/config/pwfile
it asks for the password twice then it exits normally.
I can then navigate to the mosquitto/config folder and do a ls and the pwfile I just created is there along with the mosquitto.conf file that I modified above.
So far so goodā¦
then I exit out of the shell and navigate to the mqtt/config folder and the pwfile isnāt there but the conf file is.
I tested the operation with MQTTFx and it needs a password to access the MQTT broker so I know the pwfile exists some where.
If I delete the container and reload it then the container wonāt come up because the pwfile no longer exists to be loaded by the conf file.
And thatās the questionā¦
Why isnāt the pwfile actually writing to a persistent folder on the host?
So dumb question. Iām thinking of getting a Nuc but in the mean time decided to play with docker on a Pi.
Installed Raspbian and Docker and installed Home Assistant. Trying to make sense of docker-composeā¦
How do I make Home Assistant come up when the Pi boots up? I canāt seem to crack it and if I run docker compose up -d it pulls the ālatestā HA again and itās not good!
$ cat home-assistant.yaml
version: '3'
services:
home-assistant:
container_name: home-assistant
image: homeassistant/home-assistant:latest
restart: unless-stopped
network_mode: host
devices:
- /dev/ttyACM0:/dev/zstick
environment:
- TZ=Europe/Stockholm
volumes:
- /docker/home-assistant:/config
the password needs to be persistent. You need to add a volume to store it. this is my docker compose
mqtt:
container_name: mqtt
image: eclipse-mosquitto
restart: unless-stopped
volumes:
- /srv/docker/mosquitto/config/mosquitto.conf:/mosquitto/config/mosquitto.conf
- /srv/docker/mosquitto/config/passwd:/mosquitto/config/passwd
- /srv/docker/mosquitto/log:/mosquitto/log
- /srv/docker/mosquitto/data:/mosquitto/data
- /etc/localtime:/etc/localtime:ro
environment:
- PGID=1000
- PUID=1000
ports:
- "1883:1883"
- "9001:9001"
make sure you save your password file to that location and itāll be fine.
Ok, thanks.
I forgot that I changed from the persistent /config as a directory to the persistent /config/mosquitto.conf as a file.
That makes perfect sense when you point it out.
So I would still open a shell session in the container to create the password file and save it to the āpasswdā file like this?:
mosquitto_passwd -c /mosquitto/config/passwd
I tried it the way I posted above but I got the error:
āError: Unable to open file /mosquitto/config/passwd for writing. Is a directory.ā
I googled and found some issues that said if the container canāt find the volume file it creates an empty directory instead so I then removed the container and created a blank passwd file (not a directory) in the mqtt/config/ folder and tried it again with the same result.
so once more here is the docker run command iām using after modifying it to try to fix file permission errors:
sudo docker run -itd --name=eclipse-mosquitto -p 1884:1883 -p 9002:9001 -v /home/finity/docker/mqtt/config/mosquitto.conf:/mosquitto/config/mosquitto.conf -v /home/finity/docker/mosquitto/config/passwd:/mosquitto/config/passwd -v /home/finity/docker/mqtt/data:/mosquitto/data -v /home/finity/docker/mqtt/log:/mosquitto/log -e PGID=1000 -e PUID=1000 -e UMASK_SET=000 eclipse-mosquitto
Ok, so here is the next strange thingā¦
After removing the container using Portainer and selecting to remove non-persistent volumes then recreating it for some reason the pwfile still exists in the container at mosquitto/config/passwd/pwfile. And I can connect to the MQTT broker using MQTTFx with my user name & password I created in the pwfile.
But I canāt find that file ANYWHERE on the host. Iām really not sure whatās going on.
As far as I can see, the only place that pwfile file exists is in the container and I deleted the container and rebuilt it. But the pwfile still sticks around somehow.
If for some reason the file is persisting shouldnāt I be able to see the file on the host at mqtt/config/passwd? But that folder doesnāt exist on the host. I deleted it.
no need, you say you already have a non-docker running instance. copy that same file to the appropriate docker directory.
your mosquito.conf also needs to be like this
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /mosquitto/data/
# Port to use for the default listener.
port 1883
log_dest file /mosquitto/log/mosquitto.log
log_dest stdout
allow_anonymous false
password_file /mosquitto/config/passwd
# user mosquitto
# Place your local configuration in /mqtt/config/conf.d/
# include_dir /mqtt/config/conf.d
note it includes the password file path
Never mindā¦ I found itā¦
I missed changing the āā¦/mosquitto/passwdā in your config to āā¦/mqtt/passwdā to match mine.
Itās all fixed now. thanks for the help.