Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to expose a USB device to an LXC/Docker container?

I have an embedded system development image contained in a Docker file. In order to flash the code I need to connect to the nodes via USB Serial (e.g. /dev/ttyACM0).

With Docker I used the new bind mount feature to (see https://github.com/dotcloud/docker/issues/111, -b or more recently the -v option) to expose the hosts devfs to the container. However, whenever I connect ("cat /d/ttyACM0", d is the bind mount to dev) to the device I get "operation not permitted". Is it possible to not only bind mount, but actually use character devices in the container?

Would it be maybe even possible to expose specific devs via udev rules?

like image 793
till Avatar asked Jul 22 '13 16:07

till


2 Answers

At the current moment, this is not possible with Docker. However, we are working on a 'privilege' mode that would allow a container to access devices like USB or GPU.

like image 126
creack Avatar answered Oct 07 '22 01:10

creack


The --device option now allows exposing a /dev to a container, for example:

docker run -t -i --device=/dev/ttyUSB0 ubuntu bash

(I found from this Stack Overflow answer.)

like image 27
tuomassalo Avatar answered Oct 07 '22 02:10

tuomassalo