How do I access USB devices in a Docker container on Ubuntu?

0
4
Asked By SunnyKiwi99 On

I'm using Docker Desktop on my Ubuntu 24 machine and need to access USB devices connected to my host, specifically through ttyUSB. I tried using the command 'docker run -it --device=/dev/ttyUSB0 --name dev_env ubuntu:22.04', but I encountered an error saying 'docker: Error response from daemon: error gathering device information while adding custom device "/dev/ttyUSB0": no such file or directory', even though the ttyUSB0 device is available in the /dev directory. Any advice on how to resolve this?

1 Answer

Answered By TechieTurtle22 On

First, check what 'ls -al /dev/ttyUSB0' shows on your host. Sometimes, you might need specific group permissions. For instance, you might need to be part of the 'dialout' group or run it as root/sudo. So, make sure your current user has the right access.

CuriousCoder77 -

It shows crw-rw-rw-+ 1 root dialout. And yes, by default Docker doesn’t require root/sudo.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.