[lxc-users] How to provide device access to lxc unprivileged containers ?

Yasoda Padala padala.yasoda at gmail.com
Tue Sep 11 08:45:32 UTC 2018


Hi All,
I have a usb attached to my ubuntu machine (16.04) and trying to access
that device from unprivileged lxc container.
By access I mean, enumerate and do I/O on that device.
I have written a small program using libusb library and using that libusb
executable to enumerate,read/write usb device from container
Please find attached  lxc config file and libusb executable.
I have found plenty of examples in various forums but nothing worked for me.

Tried the following:
1. Added below entries in lxc config file
lxc.cgroup.devices.allow = b 8:* rwm
lxc.mount.entry = /dev/bus/usb/001/ dev/bus/usb/001/ none bind,create=dir 0
0
lxc.mount.entry = /dev/sdc /home/oxpd/.local/share/lxc/Test/rootfs/dev/sdc
none bind,create=file 0 0
lxc.mount.entry = /dev/sdc1
/home/oxpd/.local/share/lxc/Test/rootfs/dev/sdc1 none bind,create=file 0 0

2. Changed device owner to 100000
3. changed device permission to 777.on the host

when I run the libusb executable on host, all the attached device are
listed, but the same when I run inside the container it says 0 devices are
attached.
Is there any other configuration I am missing. Please help.

Thanks & Regards,
Yasoda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20180911/596b8d88/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: config
Type: application/octet-stream
Size: 1026 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20180911/596b8d88/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libusb
Type: application/octet-stream
Size: 13896 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20180911/596b8d88/attachment-0001.obj>


More information about the lxc-users mailing list