Error response from daemon: error gathering device information while adding custom device

Hi, I cannot map my usb device with the docker container in Linux (POP OS).

These are the current permissions:

$ ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 nov 27 09:28 /dev/ttyUSB0
$ groups
adm dialout sudo audio kvm lpadmin docker

I mapped ttyUSB0 device in my docker compose file:

    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0

And this is the error when I run the container:

$ docker compose up
Error response from daemon: error gathering device information while adding custom device "/dev/ttyUSB0": no such file or directory

If I add the priviliged property to the compose file I can run the container but I get this error when serial port is used:

    priviliged: true
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0

And this is the error:

File "/usr/local/lib/python3.10/site-packages/serial/serialposix.py", line 325, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyUSB0: [Errno 2] No such file or directory: '/dev/ttyUSB0'

If I run docker compose up with sudo all works correctly, so I think itā€™s just a permissions issue.

I canā€™t figure out how to correctly map the USB device to the container.

1 Like

I noticed that this error occurs only when docker desktop is running.

What is the connection between the two?

1 Like

After I gave up on a ongoing troubleshooting a while ago, I tried, today, to get once again audio out of a container using the /dev/snd device mapping. By luck, Google redirected me to someone who had a similar issue and I finally got any sense of why my Mopidy dockerfile stopped working. I had ipsis verbis the same error when running my compose app, but for the /dev/snd mapping, and I can validate that indeed it can be a problem of using Docker Desktop, because on my previous system installation I had the ā€œusualā€ Docker CE instead and had no problems whatsoever. Kinda dumb of myself for not figuring it out earlierā€¦ Having the GUI is neat but if I canā€™t run my stuff properlyā€¦ I donā€™t know. I might think twice.

Thank you for sharing your experience! Docker Desktop is great, but it is not for everything. I think knowing what is it for and what is it not for is the key for good experience and productivity. Iā€™d say the fact that Docker Desktop gives us preconfigured client-server connection between the host and the virtual machine makes it easier to use on Windows and macOS for simple tasks when we donā€™t want to use anything closer to the kernel or the hardware, but we still need to know about Docker CE. I donā€™t think it will ever change, however one day using soundcard or usb devices with Docker Desktop may become easier if it is possible to solve and enough people ask for it.

You can try here:

but I think it could be years until we can see a feature like that. On the other hand, who knows? Docker Desktop can already use NVIDIA GPUs: WSL 2 GPU Support for Docker Desktop on NVIDIA GPUs - Docker

1 Like