E0748: Configurar desde cero una Raspberry Pi
Da igual el modelo que sea.
En este jueves domótico cuento exactamente lo que tardo en configurar desde cero y poner en marcha una nueva Raspberry Pi para domótica. Acceso por SSH, cuatro programas, Docker y a funcionar.
- Keep Pushing F1 (especial Inocentes)
- Raspberry Pi Imager para descargar RPi OS
- Aumentar memoria Swap
- Instalar Docker (con Compose incluido):
- sudo curl -fsSL https://get.docker.com/ -o get-docker.sh
- sudo sh get-docker.sh
- sudo usermod -aG docker <USUARIO>
- Episodio 616: Raspberry Pi con SSD
- Episodio 734: Mi nueva Raspberry Pi 5 y la migración de Home Assistant
version: '3.8'
networks:
principal:
driver: bridge
driver_opts:
com.docker.network.bridge.enable_ip_masquerade: "true"
com.docker.network.bridge.enable_icc: "true"
com.docker.network.bridge.host_binding_ipv4: "0.0.0.0"
com.docker.network.bridge.name: "docker30"
com.docker.network.driver.mtu: "1500"
ipam:
driver: default
config:
- subnet: 172.30.0.0/24
services:
autoheal:
image: willfarrell/autoheal:latest
container_name: Autoheal
hostname: Autoheal
restart: always
networks:
principal:
ipv4_address: 172.30.0.6
security_opt:
- seccomp:unconfined
environment:
- AUTOHEAL_CONTAINER_LABEL=true
- AUTOHEAL_DEFAULT_STOP_TIMEOUT=20
volumes:
- /var/run/docker.sock:/var/run/docker.sock
cloudflared:
container_name: Cloudflared
image: visibilityspots/cloudflared:alpine-3.12
restart: unless-stopped
network_mode: host
environment:
- METRICS=127.0.0.1:58080
homeassistant:
image: ghcr.io/home-assistant/home-assistant:stable
container_name: HomeAssistant
restart: unless-stopped
network_mode: host
privileged: true
security_opt:
- seccomp:unconfined
volumes:
- /etc/localtime:/etc/localtime:ro
- /run/dbus:/run/dbus:ro
- /home/pi/docker/homeassistant:/config
mosquitto:
image: eclipse-mosquitto:latest
container_name: Mosquitto
hostname: Mosquitto
restart: unless-stopped
networks:
principal:
ipv4_address: 172.30.0.4
ports:
- 1883:1883
environment:
- TZ=Europe/Madrid
volumes:
- /home/pi/docker/mosquitto/config:/mosquitto/config
- /home/pi/docker/mosquitto/data:/mosquitto/data
- /home/pi/docker/mosquitto/log:/mosquitto/log
nodered:
image: nodered/node-red:latest
container_name: NodeRed
hostname: NodeRed
restart: unless-stopped
networks:
principal:
ipv4_address: 172.30.0.7
ports:
- "1880:1880"
security_opt:
- seccomp:unconfined
environment:
- TZ=Europe/Madrid
volumes:
- /home/pi/docker/nodered:/data
pihole:
image: pihole/pihole:latest
container_name: PiHole
restart: unless-stopped
network_mode: host
cap_add:
- NET_ADMIN
security_opt:
- seccomp:unconfined
dns:
- 127.0.0.1
- 1.1.1.1
environment:
- TZ=Europe/Madrid
- WEBPASSWORD=<PASSWORD>
- FTLCONF_REPLY_ADDR4=<IP de la RPi>
- INTERFACE=eth0
- PIHOLE_DNS_=127.0.0.1#5054
- IPv6=false
volumes:
- /home/pi/docker/pihole/config/:/etc/pihole/
- /home/pi/docker/pihole/dnsmasq.d/:/etc/dnsmasq.d/
portainer:
image: portainer/portainer-ce:latest
container_name: Portainer
hostname: Portainer
restart: always
networks:
principal:
ipv4_address: 172.30.0.200
ports:
- "9000:9000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/pi/docker/portainer:/data
wgeasy:
image: weejewel/wg-easy:latest
container_name: WireGuard_Easy
hostname: WireGuard_Easy
restart: unless-stopped
networks:
principal:
ipv4_address: 172.30.0.210
cap_add:
- NET_ADMIN
- SYS_MODULE
ports:
- "51820:51820/udp"
- "51821:51821"
environment:
- WG_HOST=<URL del host>
- PASSWORD=<PASSWORD WEB>
- WG_PERSISTENT_KEEPALIVE=30
- WG_DEFAULT_ADDRESS=<RED DE LA VPN>
- WG_DEFAULT_DNS=<IP DEL DNS>
- WG_ALLOWED_IPS=192.168.0.0/16
volumes:
- /home/pi/docker/wireguard_easy/:/etc/wireguard/
- /lib/modules/:/lib/modules/
sysctls:
- net.ipv4.conf.all.src_valid_mark=1
- net.ipv4.ip_forward=1
zigbee2mqtt:
image: koenkk/zigbee2mqtt:latest
container_name: zigbee2mqtt
restart: always
network_mode: host
privileged: true
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
environment:
- TZ=Europe/Madrid
volumes:
- /home/pi/docker/zigbee2mqtt:/app/data
- /run/udev:/run/udev:ro