Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Discuss
  3. USB hardware and Cloudron Docker images

USB hardware and Cloudron Docker images

Scheduled Pinned Locked Moved Discuss
13 Posts 4 Posters 2.1k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jadudmJ jadudm

      The question: Is it possible for me to have a Cloudron Docker container that grabs a USB serial device?


      I have set up Home Assistant in a Cloudron container, and mosquitto (an MQTT broker) in another. They talk to each-other. They're friends.

      I would like to have a container running zigbee2mqtt. This is a node app that talks to a USB zigbee adapter (I'm using this one).

      Is it possible for me to have a Cloudron Docker container that grabs that USB device?

      If I was spinning this up outside of Cloudron, I'd use the devices tag in my docker-compose.yml. (This is the zigbee2mqtt compose, for reference.)

      girishG Offline
      girishG Offline
      girish
      Staff
      wrote on last edited by
      #4

      @jadudm Devices are not exposed to containers. Usually, we add a flag in the manifest and expose devices to containers as needed. The idea being that in the future we can atleast "warn" or "inform" the user that the app wants to use the device. For example, emby uses the graphics card for vaapi api use. For example, https://git.cloudron.io/cloudron/box/-/blob/master/src/docker.js#L390

      You can patch that specific function to add more devices there. If you can tell me what or how to expose the USB devices to the container, we can try to adjust the manifest accordingly.

      mehdiM 1 Reply Last reply
      1
      • girishG girish

        @jadudm Devices are not exposed to containers. Usually, we add a flag in the manifest and expose devices to containers as needed. The idea being that in the future we can atleast "warn" or "inform" the user that the app wants to use the device. For example, emby uses the graphics card for vaapi api use. For example, https://git.cloudron.io/cloudron/box/-/blob/master/src/docker.js#L390

        You can patch that specific function to add more devices there. If you can tell me what or how to expose the USB devices to the container, we can try to adjust the manifest accordingly.

        mehdiM Offline
        mehdiM Offline
        mehdi
        App Dev
        wrote on last edited by
        #5

        @girish It usually depends on the device, but in this usecase (a zigbee usb stick), it's a TTY to USB device that has to be passed. I got something similar in my local HA install, and here's the relevant docker-compose bit:

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

        I believe the equivalent docker run option would be:

        --device=/dev/ttyUSB0:/dev/ttyUSB0
        
        1 Reply Last reply
        0
        • mehdiM Offline
          mehdiM Offline
          mehdi
          App Dev
          wrote on last edited by
          #6

          Of course, the thing is the device being passed should be configurable by the user : you can't blindly pass ttyUSB0 and assume it will always work.

          1 Reply Last reply
          0
          • girishG Offline
            girishG Offline
            girish
            Staff
            wrote on last edited by
            #7

            @mehdi Ah, I see. Maybe we need device permission and some sort of device selector in the UI.

            robiR 1 Reply Last reply
            2
            • girishG girish

              @mehdi Ah, I see. Maybe we need device permission and some sort of device selector in the UI.

              robiR Offline
              robiR Offline
              robi
              wrote on last edited by
              #8

              @girish Right, device enumeration happens at the OS level, and it's not always consistent for silly kernel reasons.

              From there one needs to be able to list all USB devices and have the user choose or add additional code to interrogate all USB devices for hints and choose automatically based on what the app is looking for (zigbee vs mouse/keyb).

              Conscious tech

              girishG 1 Reply Last reply
              0
              • robiR robi

                @girish Right, device enumeration happens at the OS level, and it's not always consistent for silly kernel reasons.

                From there one needs to be able to list all USB devices and have the user choose or add additional code to interrogate all USB devices for hints and choose automatically based on what the app is looking for (zigbee vs mouse/keyb).

                girishG Offline
                girishG Offline
                girish
                Staff
                wrote on last edited by
                #9

                @robi indeed, I guess additional complication is also that device names can change.

                robiR 1 Reply Last reply
                1
                • girishG girish

                  @robi indeed, I guess additional complication is also that device names can change.

                  robiR Offline
                  robiR Offline
                  robi
                  wrote on last edited by
                  #10

                  @girish yes, but generally only during major OS upgrades and new ways of handling of those driver subsystems.

                  Conscious tech

                  girishG 1 Reply Last reply
                  0
                  • robiR robi

                    @girish yes, but generally only during major OS upgrades and new ways of handling of those driver subsystems.

                    girishG Offline
                    girishG Offline
                    girish
                    Staff
                    wrote on last edited by
                    #11

                    @robi I think it also changes with the physical USB port that the device connects to (?)

                    robiR 1 Reply Last reply
                    0
                    • girishG girish

                      @robi I think it also changes with the physical USB port that the device connects to (?)

                      robiR Offline
                      robiR Offline
                      robi
                      wrote on last edited by
                      #12

                      @girish it can, since many systems now have a transitional period of USB2.0 and USB 3.0 hubs.

                      Conscious tech

                      1 Reply Last reply
                      0
                      • mehdiM Offline
                        mehdiM Offline
                        mehdi
                        App Dev
                        wrote on last edited by
                        #13

                        Another, safer, way, would be to use the alternative paths. In my case, that would be /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0 or /dev/serial/by-path/platform-3f980000.usb-usb-0:1.5:1.0-port0

                        1 Reply Last reply
                        2
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Bookmarks
                          • Search