Reading time: 2 minutes
Today we are going to see how we can install Home Assistant on a Raspberry Pi using Docker.
The first thing we need to have ready is the installation of Docker on our Raspberry Pi: https://devcodelight.com/desplegar-servidor-web-apache-con-docker-compose/
We are going to use this structure:

Once installed, we will need to create this Docker Compose configuration.
docker-compose.yml
version: '3'
services:
homeassistant:
container_name: homeassistant
image: homeassistant/home-assistant
volumes:
- ./config/hass_config:/config
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
ports:
- "8123:8123"
depends_on:
- mariadb_home_assistant
- mosquitto
networks:
- docker-network
mariadb_home_assistant:
image: mariadb
container_name: mariadb_home_assistant
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: "MYSQL_ROOT_PASSWORD"
MYSQL_DATABASE: ha_db
MYSQL_USER: homeassistant
MYSQL_PASSWORD: "MYSQL_PASSWORD"
volumes:
- ./config/mariadb:/config
ports:
- "3306:3306"
networks:
- docker-network
nodered:
container_name: nodered
image: nodered/node-red
ports:
- "1880:1880"
volumes:
- ./config/nodered:/data
depends_on:
- homeassistant
- mosquitto
environment:
TZ: "Europe/Madrid"
restart: unless-stopped
networks:
- docker-network
mosquitto:
image: eclipse-mosquitto
container_name: mosquitto_z
restart: unless-stopped
ports:
- "1883:1883"
volumes:
- "./config/mosquitto/config:/mosquitto/config"
- "./config/mosquitto/data:/mosquitto/data"
- "./config/mosquitto/log:/mosquitto/log"
environment:
- TZ=Europe/Madrid
user: "${PUID}:${PGID}"
networks:
- docker-network
hass-configurator:
image: "causticlab/hass-configurator-docker:arm"
container_name: hass-configurator
restart: unless-stopped
ports:
- "3218:3218/tcp"
depends_on:
- homeassistant
volumes:
- "./config/configurator:/config"
- "./config/hass_config:/hass-config"
user: "${PUID}:${PGID}"
networks:
- docker-network
networks:
docker-network:
driver: bridge
external: true
We will choose the password we want to set for root_password / db_user_password
Now we create the file config/configurator/settings.conf
{
"BASEPATH": "../hass_config"
}
Now we create the file config/hass_config/configuration.yalm
We modify <host_ip> with the IP of the Raspberry Pi on our internal network.
default_config:
http:
use_x_forwarded_for: false
panel_iframe:
configurator:
title: Configurator
icon: mdi:wrench
url: http://<host_ip>:3218/
require_admin: true
nodered:
title: Node-Red
icon: mdi:shuffle-variant
url: http://<host_ip>:1880/
require_admin: true
recorder:
db_url: mysql://homeassistant:<MYSQL_PASSWORD>@mariadb_home_assistant/ha_db?charset=utf8
purge_keep_days: 30
We modify MYSQL_PASSWORD with the value we gave it in the previous .env variable.
This configuration file will contain the entire panel of our Home Assistant and will be modified.
More info: https://www.danielmartingonzalez.com/es/configuracion-de-home-assistant-en-yaml/
Now we create the file config/mosquitto/config/mosquitto.conf
persistence true persistence_location /mosquitto/data/ log_dest file /mosquitto/log/mosquitto.log listener 1883 allow_anonymous true
We will create this .gitignore if we use Git to store the code:
config/configurator/* config/homeassistant/* config/mariadb/* config/mosquitto/* config/nodered/*
*This should be created after uploading the configuration files to prevent data loss.
Now let’s deploy the docker compose with this command:
docker compose up -d
To access Node-RED:
http://ip_raspberry:1880
Access the Home Assistant configurator:
http://localhost:3218/
To access Home Assistant:
http://localhost:8123

