# Explicitly map /dev/\* devices without privileged mode

**URL:** <https://forums.balena.io/t/explicitly-map-dev-devices-without-privileged-mode/5949>\
**Category:** balenaOS\
**Tags:** support, docker\
**Created:** [April 9, 2019, 10:05am UTC](https://forums.balena.io/t/explicitly-map-dev-devices-without-privileged-mode/5949 "2019-04-09T10:05:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![galvesribeiro](https://avatars.discourse-cdn.com/v4/letter/g/c0e974/32.png) [@galvesribeiro](https://forums.balena.io/u/galvesribeiro)\
**Post date:** [April 9, 2019, 10:05am UTC](https://forums.balena.io/t/explicitly-map-dev-devices-without-privileged-mode/5949/1 "2019-04-09T10:05:06Z")

</div>

Hello folks!

If I understood correctly, it looks like in order to make `evdev` to run on the container and allow access to devices on `/dev/*`, the container must be set as `privileged` which means, the host will map _all_ the devices on the container.

Although it works, it is far from ideal security-wise if you consider the least privilege idea.

So, is there a way to map only the devices I want on a particular container and start `evdev` only with them?

Thank you!  
Gutemberg

---

<div class="post-metadata">

**Author:** ![majorz](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/majorz/32/639_2.png) [@majorz](https://forums.balena.io/u/majorz)\
**Post date:** [April 9, 2019, 11:19am UTC](https://forums.balena.io/t/explicitly-map-dev-devices-without-privileged-mode/5949/4 "2019-04-09T11:19:19Z")

</div>

Yes, there is an alternative. Please check this page to see how to do that: [https://www.balena.io/docs/learn/develop/hardware/](https://www.balena.io/docs/learn/develop/hardware/)

---

<div class="post-metadata">

**Author:** ![galvesribeiro](https://avatars.discourse-cdn.com/v4/letter/g/c0e974/32.png) [@galvesribeiro](https://forums.balena.io/u/galvesribeiro)\
**Post date:** [April 9, 2019, 2:01pm UTC](https://forums.balena.io/t/explicitly-map-dev-devices-without-privileged-mode/5949/5 "2019-04-09T14:01:25Z")

</div>

I’ve saw that but I couldn’t make it work.

> use the `cap_add` and `devices` settings to map in the correct hardware access to the container

What are the permissions that I need to add there for:

1. USB Printer
2. Linux Framebuffer
3. USB Serial device

Since the application requires access to invoke `ioctl` APIs, idk if `SYS_RAWIO` is correct…

Thanks

---

<div class="post-metadata">

**Author:** ![shaunmulligan](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/shaunmulligan/32/34_2.png) [@shaunmulligan](https://forums.balena.io/u/shaunmulligan)\
**Post date:** [April 9, 2019, 5:09pm UTC](https://forums.balena.io/t/explicitly-map-dev-devices-without-privileged-mode/5949/6 "2019-04-09T17:09:05Z")

</div>

Hi @galvesribeiro, I think for the USB device specifically you probably will need to use a privileged container, since most usb devices can enumerate to a different number. One way to make sure the usb devices have a fixed name is to set a hostOS udev rule to map it to a specific name. Have a look at this blog post [https://www.balena.io/blog/balena-fin-gps-tracker-project/](https://www.balena.io/blog/balena-fin-gps-tracker-project/) (specifically the section titled " Custom udev rules" which maps the modem (usb-serial) device to `/dev/NMEA.gps` and then that device gets mapped into the container using the `--device` compose directive.
