Home Assistant in Docker - pass USB device from host

Here’s my docker-compose.yaml:

version: '3'
services:
  homeassistant:
    container_name: home-assistant
    image: homeassistant/raspberrypi3-homeassistant:stable
    volumes:
    - /home/pi/.hass:/config
    devices:
    - /dev/ttyUSB0:/dev/ttyUSB0
    - /dev/ttyUSB1:/dev/ttyUSB1
    - /dev/hidraw0:/dev/hidraw0
    - /dev/hidraw1:/dev/hidraw1
    environment:
    - TZ=America/Chicago
    restart: unless-stopped
    network_mode: host

The devices: section passes my USB devices from the host to the container. If you’re using a docker run command, then add the --device flag with the appropriate devices: https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities

3 Likes