How to setup ubuntu, docker-compose and home assistant, with a zigbee dongle and portainer
sudo apt update
sudo apt upgrade -y
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install docker-ce -y
sudo systemctl status docker
sudo usermod -aG docker $USER
Log out and log back in for the change to take effect.
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r .tag_name)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
sudo systemctl enable docker
services:
homeassistant:
container_name: homeassistant
# this specific image works for aqara fp2 which is broken on latest as of dec 22 2024
image: "ghcr.io/home-assistant/home-assistant:2024.5.1"
volumes:
- /home/mike/Desktop/ha/config:/config
- /etc/localtime:/etc/localtime:ro
- /run/dbus:/run/dbus:ro
- /run/pulse:/run/pulse:ro
- /dev/snd:/dev/snd
devices:
- "/dev/serial/by-id/usb-Itead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_V2_f4a612428639ef119fb057f454516304-if00-port0:/dev/zigbee"
restart: unless-stopped
privileged: true
network_mode: host
logging:
driver: "json-file" # Use the default json-file driver
options:
max-size: "10m" # Max size of each log file before it is rotated (10MB)
max-file: "10" # Max number of log files to keep
portainer:
container_name: portainer
image: portainer/portainer-ce:latest
restart: unless-stopped
ports:
- "8000:8000" # Optional Portainer Edge agent port
- "9000:9000" # Main Portainer UI port
network_mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
volumes:
portainer_data:
Run:
sudo nano /etc/systemd/system/homeassistant.service
find your docker-compose path with which docker-compose
[Unit]
Description=Home Assistant Docker Compose Service
Requires=docker.service
After=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/home/mike/Desktop/ha
ExecStart=${PATH} up -d
ExecStop=${PATH} down
TimeoutStartSec=0
[Install]
WantedBy=multi-user.target
After saving the file, reload systemd to recognize the new service:
sudo systemctl daemon-reload
Enable it to start on boot:
sudo systemctl enable homeassistant.service
Start the service now:
sudo systemctl start homeassistant.service
Check the status to ensure it’s working as expected:
sudo systemctl status homeassistant.service