Docker Community Forums

Share and learn in the Docker community.

Cannot access USB

I am very new to Docker, but like it so far .

I run Docker on Windows 10 and run home assistant in a Linux container.

Home assistant needs access to an USB-device (not a harddisk) but I don’t het this done.

On a Raspberry I used ls /dev/tty* to get the names of the ports but tht doesn’t seem to work here.

For some people it works when using a compose.yml file so I created the same with this code :

version: '3'
services:
  homeassistant:
    container_name: hass
    image: homeassistant/home-assistant
    volumes:
      - H:/Docker/Hass/config/:/config
      - /etc/localtime:/etc/localtime:ro
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0
      - /dev/ttyUSB1:/dev/ttyUSB1
      - /dev/ttyACM0:/dev/ttyACM0
    restart: always
    network_mode: host

With docker-compose up -d I get an error saying
for homeassistant Cannot start service homeassistant: linux runtime spec devices: error gathering device information while adding custom device “/dev/ttyACM0”: no such file or directory

How to solve this ?

You can’t access hardware devices from Docker on Windows. Docker Desktop runs in Hyper-V and therefore is isolated from the base system.
This topic was discussed several times in the Homeassistant forum. If you need acccess to hardware to connect to your infrastructure, install it on Linux.
And by the way, there is no /etc/localtime on Windows, you have to use an environment variable to set the time zone.

That was something else I ran into :blush:
I installed docker on a windows machine to find out if I could understand how it works, before I buy a new Snology Nas. So you are saying running when Docker on a Synology Nas and home assistant in a container I will not get this kind of problems ?

I thought Windows Docker emulates a linux machine.
Lot to learn :wink:

Thank you for your quick ansewer by the way

I don’t say anything about Synology because I’ve never tried. But on home-assistant.io you find an example about how to connect a Z-Wave stick, so you can expect it works. If a device with a rather high power consumption is the right choice for a house automation server is another question.

Docker Desktop runs on a Linux virtual machine in Hyper-V, it’s not an emulation. If you open the Hyper-V Manager you find a ‘DockerDesktopVM’ and can inspect its properties.