Help Needed With Dockerfile That Accesses USB Resource

I’m trying to create a Dockerfile for an application (Mochad) that connects to an X10 CM15A controller via USB. 

My Dockerfile contains the following:

FROM alpine

MAINTAINER Jay Shridharani <jshridha@gmail.com>

RUN apk add --update --no-cache gcc g++ cmake make wget libusb-dev && </font>

     mkdir /build && cd /build && </font>

     wget -O mochad.tgz http://sourceforge.net/projects/mochad/files/latest/download && </font>

     tar -xzvf mochad*.t* && </font>

     cd mochad* && ./configure && make && make install && </font>

     apk --purge del gcc g++ cmake make wget && </font>

     rm -rf /var/cache/apk/* /lib/apk/db/*

CMD [“mochad”, “-d”]

When I try and run my Dockerfile I get the following error:

mochad.c:611:failed to initialise libusb -99

My OS is HASSOS running on an a Raspberry Pi 3 b+, so I only have limited access to the OS.  I am able to run lsusb which informs me that my device is seen by the OS and is on bus 1:

Bus 001 Device 007: ID 0bc7:0001

The Dockerized version of my application (https://github.com/jshridha/docker-mochad/blob/master/README.md ) has a readme file that states to run the following command:

docker run -d --name=mochad --device"/dev/bus/usb/001"jshridha/mochad:latest

I can see that the container is built but won’t run and I get the libusb initialization error indicated above.  I’m new to Linux and have spent several days pouring over discussion boards, learing about Docker and trying to figure out how to solve this issue.  Any help would be greatly appreciated!  

Hi and welcome @crberger ,

Thanks for your clear and well-formulated question! Do you have read+write abilities outside of docker to the USB?

Thanks very much for the reply @mpboom.  I’m a little embarrassed to admit it, but with my limited knowledge of Linux and being new to Hassio, I’m not sure.  Hassio has the OS pretty locked down as the OS is intended to run as an appliance.  Is there a command I can run to figure this out?  Mochad is what is used to acces the CM15A, which is my USB device.  I was able to use a USB drive during the installation of Hassio to configure my WiFi connection, so I know that during the install process I had read capapility from the OS, but I don’t know if during that setup process Hassio locked this down or not.

1 Like

You should be able to use the  cd  command on the command line to navigate to the USB and check if you can read the files on it.

I did, however, just notice you are trying to access the USB by it’s  /bus/ path. I don’t think that is going to work since in Linux you have to manually mount drives in order to access their filesystem. Here is a great thread on mounting stuff: https://askubuntu.com/a/37775, but a Google search will turn up more results I guess.