Skip to content

Instantly share code, notes, and snippets.

@x99percent
Last active April 19, 2023 00:55
Show Gist options
  • Star 51 You must be signed in to star a gist
  • Fork 18 You must be signed in to fork a gist
  • Save x99percent/d65b6f1ae4abfd64c2e1d6fffd3db371 to your computer and use it in GitHub Desktop.
Save x99percent/d65b6f1ae4abfd64c2e1d6fffd3db371 to your computer and use it in GitHub Desktop.
version: '2.1'
services:
grafana:
container_name: grafana
image: proxx/grafana-armv7
user: "1000"
ports:
- 3000:3000
volumes:
- /opt/grafana:/etc/grafana:rw
- /opt/grafana:/var/lib/grafana:rw
- /etc/timezone:/etc/timezone:ro
restart: on-failure
depends_on:
influxdb:
condition: service_healthy
influxdb:
container_name: influxdb
image: influxdb
ports:
- 8086:8086
volumes:
- /opt/influxdb/influxdb.conf:/etc/influxdb/influxdb.conf:ro
- /opt/influxdb:/var/lib/influxdb
restart: on-failure
healthcheck:
test: ["CMD", "curl", "-sI", "http://127.0.0.1:8086/ping"]
interval: 30s
timeout: 1s
retries: 24
homeassistant:
container_name: homeassistant
image: homeassistant/raspberrypi3-homeassistant:0.87.1
network_mode: "host"
volumes:
- /opt/homeassistant:/config
- /etc/localtime:/etc/localtime:ro
- /etc/letsencrypt:/etc/letsencrypt:ro
devices:
- /dev/ttyUSB0:/dev/ttyUSB0:rwm
- /dev/ttyUSB1:/dev/ttyUSB1:rwm
restart: on-failure
depends_on:
influxdb:
condition: service_healthy
mosquitto:
condition: service_started
healthcheck:
test: ["CMD", "curl", "-f", "http://127.0.0.1:8123"]
interval: 30s
timeout: 10s
retries: 6
node-red:
container_name: node-red
image: nodered/node-red-docker:rpi-v8
ports:
- 1880:1880
volumes:
- /opt/node-red:/data
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
restart: "no" # because the exit code(s) are wrong
depends_on:
mosquitto:
condition: service_started
mqtt-bridge:
condition: service_started
homeassistant:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://127.0.0.1:1880"]
interval: 30s
timeout: 10s
retries: 5
mosquitto:
container_name: mosquitto
image: eclipse-mosquitto
user: "1000:1000"
ports:
- 1883:1883
volumes:
- /etc/localtime:/etc/localtime:ro
- /opt/mosquitto:/mosquitto/config:ro
- /opt/mosquitto:/mosquitto/data
restart: on-failure
mqtt-bridge:
container_name: mqtt-bridge
build:
context: https://github.com/stjohnjohnson/smartthings-mqtt-bridge.git
dockerfile: Dockerfile-rpi
ports:
- 8080:8080
volumes:
- /opt/mqtt-bridge:/config
restart: on-failure
depends_on:
homeassistant:
condition: service_healthy
portainer:
container_name: portainer
image: portainer/portainer
ports:
- 9000:9000
volumes:
- /opt/portainer:/data:rw
- /var/run/docker.sock:/var/run/docker.sock
restart: "no" # because the exit code(s) are wrong
organizr:
container_name: organizr
image: lsioarmhf/organizr
ports:
- 80:80
- 443:443
volumes:
- /opt/organizr:/config:rw
- /etc/letsencrypt:/etc/letsencrypt:ro
environment:
- PGID=1000
- PUID=1000
restart: on-failure
healthcheck:
test: ["CMD", "curl", "-f", "http://127.0.0.1"]
interval: 30s
timeout: 10s
retries: 5
dockermon:
container_name: dockermon
image: tribunex/ha-dockermon-pi
ports:
- 8126:8126
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /opt/dockermon:/config
restart: on-failure
@Martinnygaard
Copy link

Hi,
Im following your guide on reddit, trying to setup Docker with HA on my raspberry pi.
I have a problem with DuckDNS, but the reddit threat is archived, and i cant post there.

I have ported my route to allow port 80 and 443 TCP to go to my raspberry pi IP address. (192.168.87.100)
I have set up all the steps you've had in your guide (and godt the "OK" in the log guide)

i got some errors in the Organizr docker regarding a missing file.
nginx: [emerg] BIO_new_file("/etc/letsencrypt/live/portainer.simpsonshome.duckdns.org/fullchain.pem") failed (SSL: error:02FFF002:system library:func(4095):No such file or directory:fopen('/etc/letsencrypt/live/portainer.simpsonshome.duckdns.org/fullchain.pem', 'r') error:20FFF080:BIO routines:CRYPTO_internal:no such file)

And i can indeed, the folder /etc/letsencrypt/ is completely empty. (There is no "/live" folder in it.

I hope you can help me,
Best regards,
Martin

@x99percent
Copy link
Author

I don't see how your letsencrypt directory would be empty if you've already created certs with Certbot. What do you get if you run certbot-auto renew when Organizr is stopped?

@Martinnygaard
Copy link

Martinnygaard commented Feb 10, 2020

After knowing it should be there, something must have went wrng.
I did some digging, and when reading the log from installation of the certificates, i noticed that they endeed failed.
I had to remove /etc/pip.conf from the Raspberry. [https://community.letsencrypt.org/t/certbot-auto-certificates-fails-while-installing-phyton-packages-with-these-packages-do-not-match-the-hashes/90363/6]Link(url)

Thanks for your time :-)
A shame the other topit on reddit is closed.

@Martinnygaard
Copy link

Martinnygaard commented Feb 10, 2020

This led to the next problem: Autostart of containers.

After activating the docker-compose-opt.service script, shutting down docker and restarts, it will fire up only these containers:

proxx/grafana-armv7
lsioarmhf/organizr
portainer/portainer
tribunex/ha-dockermon-pi
influxdb

Just before the restart i also had NodeRED, Mosquitto and HomeAssistant running.

THen i tried manually start them by hitting pi@SimpsonsHome:/opt $ docker-compose up -d.

dockermon is up-to-date
portainer is up-to-date
influxdb is up-to-date
Starting mosquitto ...
organizr is up-to-date
grafana is up-to-date
Starting mosquitto ... error

ERROR: for mosquitto Cannot start service mosquitto: driver failed programming external connectivity on endpoint mosquitto (a25e488206442aa55970559251babba815da2e2be10a676d77c6bd54f792f717): Error starting userland proxy: listen tcp 0.0.0.0:1883: bind: address already in use

ERROR: for mosquitto Cannot start service mosquitto: driver failed programming external connectivity on endpoint mosquitto (a25e488206442aa55970559251babba815da2e2be10a676d77c6bd54f792f717): Error starting userland proxy: listen tcp 0.0.0.0:1883: bind: address already in use
ERROR: Encountered errors while bringing up the project.

I used pi@SimpsonsHome:/opt $ docker-compose down to shut down my containers again (Note: now all of them are listed)

pi@SimpsonsHome:/opt $ docker-compose down
Stopping grafana ... done
Stopping organizr ... done
Stopping portainer ... done
Stopping dockermon ... done
Stopping influxdb ... done
Removing grafana ... done
Removing organizr ... done
Removing portainer ... done
Removing dockermon ... done
Removing influxdb ... done
Removing mosquitto ... done
Removing network opt_default

then located which process that is using mosquittos address:

pi@SimpsonsHome:/opt $ sudo lsof -i -P -n | grep 1883
mosquitto 419 mosquitto 5u IPv4 15595 0t0 TCP *:1883 (LISTEN)
mosquitto 419 mosquitto 6u IPv6 15596 0t0 TCP *:1883 (LISTEN)

then i killed the process:

pi@SimpsonsHome:/opt $ sudo kill 419

And started ducker back up:

pi@SimpsonsHome:/opt $ docker-compose up -d
Creating network "opt_default" with the default driver
Creating dockermon ... done
Creating influxdb ... done
Creating organizr ... done
Creating portainer ... done
Creating mosquitto ... done
Creating grafana ... done
Creating homeassistant ... done
Creating node-red ... done

And now everything is working again.
My conclusion is that the mosquitto service does not get killed during reboot, and then it cannot start again during startup (Because old instance of Mosquitto is blocking the new instance)

Ant idea on how to fix this?
I am out of ideas.

@x99percent
Copy link
Author

Either uninstall or disable the old mosquitto instance.

@Martinnygaard
Copy link

Yeah, i tried that, but the problem is that next time i reboot - the problem is back again.
It's like the instance from before last reboot is fucking the current container up.

Is mosquitto have been working and i reboot (and also if i shut mosquito down first) - it will always fail next boot.

@x99percent
Copy link
Author

x99percent commented Feb 13, 2020

Note that I did not say "shut down the old mosquitto instance". Even if you stop it, a service that is still ENABLED will start right back up when you reboot.

apt search mosquitto ...look for items that say [installed] and uninstall them.

To be more clear: mosquitto that you have installed DIRECTLY on the system is interfering with the mosquitto that you're trying to run in docker.

@Martinnygaard
Copy link

Martinnygaard commented Feb 14, 2020

Thanks a lot!
I did the search, deleted the instance running directly on my Pi and rebooted - everything worked like a charm!

I really appriciate your help!
The guide you made - aswell as another RPi4 orientated guide (refering to yours) are the two single best entry angle, when a person have no knowledge about docker. Great work.

Wounder how this instance got installed on the pi in the first place - where i fucked up.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment