Title: Hotplug events do not fire when application is running inside of a docker container · Issue #90 · usb4java/usb4java · GitHub
Open Graph Title: Hotplug events do not fire when application is running inside of a docker container · Issue #90 · usb4java/usb4java
X Title: Hotplug events do not fire when application is running inside of a docker container · Issue #90 · usb4java/usb4java
Description: Environment: OS: Debian Bullseye Java version Temurin JDK 21 (repeatable in Amazon Corretto 17 and 11 as well) usb4java version 1.3.0 Bug description When running an application on Linux on the host, you can run a java application and ha...
Open Graph Description: Environment: OS: Debian Bullseye Java version Temurin JDK 21 (repeatable in Amazon Corretto 17 and 11 as well) usb4java version 1.3.0 Bug description When running an application on Linux on the hos...
X Description: Environment: OS: Debian Bullseye Java version Temurin JDK 21 (repeatable in Amazon Corretto 17 and 11 as well) usb4java version 1.3.0 Bug description When running an application on Linux on the hos...
Opengraph URL: https://github.com/usb4java/usb4java/issues/90
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Hotplug events do not fire when application is running inside of a docker container","articleBody":"**Environment:**\r\n - OS: Debian Bullseye\r\n - Java version Temurin JDK 21 (repeatable in Amazon Corretto 17 and 11 as well)\r\n - usb4java version 1.3.0\r\n\r\n**Bug description**\r\nWhen running an application on Linux on the host, you can run a java application and have the attach and detach events fire. When running the same application in a Docker container, those events will not fire. Further, trying to manually poll the USB devices and compare old/new is not possible, as the devices returned from `UsbHostManager.getUsbServices().getRootUsbHub()` are always the same. Ex. When a device is no longer attached, it will still appear in the list if it was attached at startup.\r\n\r\n**Reproduction**\r\n1. Compile the code below into a jar file.\r\n```\r\nimport javax.usb.UsbException;\r\nimport javax.usb.UsbHostManager;\r\nimport javax.usb.event.UsbServicesEvent;\r\nimport javax.usb.event.UsbServicesListener;\r\n\r\npublic class Application {\r\n\r\n public static void main(String[] args) throws UsbException, InterruptedException {\r\n UsbHostManager.getUsbServices().addUsbServicesListener(new UsbServicesListener() {\r\n @Override\r\n public void usbDeviceAttached(UsbServicesEvent event) {\r\n System.out.println(\"Device attached.\");\r\n }\r\n\r\n @Override\r\n public void usbDeviceDetached(UsbServicesEvent event) {\r\n System.out.println(\"Device detached.\");\r\n }\r\n });\r\n\r\n Thread.sleep(15000);\r\n }\r\n}\r\n\r\n```\r\n3. Run on a linux machine with sudo. `sudo java -Djava.security.egd=file:/dev/./urandom -jar app.jar`\r\n4. Connect and disconnect USB devices to see console output.\r\n5. Build the jar into a container and use the below Dockerfile to build with `sudo docker build --build-arg=\"JAR_FILE=app.jar\" -t test1 .`\r\n```\r\nFROM eclipse-temurin:21-jre-jammy\r\nARG JAR_FILE\r\nCOPY ${JAR_FILE} /usr/app/app.jar\r\nENTRYPOINT [\"java\",\"-Djava.security.egd=file:/dev/./urandom\",\"-jar\",\"/usr/app/app.jar\"]\r\n```\r\n6. Run the container with `sudo docker run -it --rm --privileged test1:latest`\r\n7. Observe that connecting and disconnecting does not fire the event.\r\n\r\n**Expected behavior**\r\nI expect that the application running in a container with the correct privileges' would allow firing of the attach and detach events.\r\n","author":{"url":"https://github.com/westinpigott","@type":"Person","name":"westinpigott"},"datePublished":"2023-12-07T20:30:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/90/usb4java/issues/90"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:69daedeb-55e6-7c83-55aa-be65c710f704 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A3E0:3930F2:E82A4FA:12E509D3:69773F31 |
| html-safe-nonce | 04463c4b86676eb2717bd2f379fa9052e186a04c6455d8e97bdc170fa8729975 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBM0UwOjM5MzBGMjpFODJBNEZBOjEyRTUwOUQzOjY5NzczRjMxIiwidmlzaXRvcl9pZCI6IjcyNDUyNTMyMjMyODE4MDMwNTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2a8efef1e8e262571ce692245e1c2361fbd0d917424b054d234bb9010b909aa2 |
| hovercard-subject-tag | issue:2031479560 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/usb4java/usb4java/90/issue_layout |
| twitter:image | https://opengraph.githubassets.com/56cad38ab6220c1c044ff86155a7fcc117c4673fb553500e6b29ca3e29e87e36/usb4java/usb4java/issues/90 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/56cad38ab6220c1c044ff86155a7fcc117c4673fb553500e6b29ca3e29e87e36/usb4java/usb4java/issues/90 |
| og:image:alt | Environment: OS: Debian Bullseye Java version Temurin JDK 21 (repeatable in Amazon Corretto 17 and 11 as well) usb4java version 1.3.0 Bug description When running an application on Linux on the hos... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | westinpigott |
| hostname | github.com |
| expected-hostname | github.com |
| None | 01d198479908d09a841b2febe8eb105a81af2af7d81830960fe0971e1f4adc09 |
| turbo-cache-control | no-preview |
| go-import | github.com/usb4java/usb4java git https://github.com/usb4java/usb4java.git |
| octolytics-dimension-user_id | 5460495 |
| octolytics-dimension-user_login | usb4java |
| octolytics-dimension-repository_id | 1528861 |
| octolytics-dimension-repository_nwo | usb4java/usb4java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1528861 |
| octolytics-dimension-repository_network_root_nwo | usb4java/usb4java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8b4769605623191b876ce084a47e46d8431b205a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width