Serial Binding not working in Docker Container

Hello everyone,
I have a problem with my Serial Binding in my openHAB Docker-based setup. Although I found many related posts, for all of those adding the EXTRA_JAVA_OPTS semmed to solve the problem.

But for me, sending command from openHAB to a serial device connected to the docker host does not work. I get the following log entries:

Could not open serial port /dev/ttyUSB0: Serial port '/dev/ttyUSB0' could not be found. Available ports are:
full log related to issue (very long!)
2020-07-09 23:33:03.083 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'serial' of item 'RF_C' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: Could not open serial port /dev/ttyUSB0: Serial port '/dev/ttyUSB0' could not be found. Available ports are:

	at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:55) ~[?:?]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:369) ~[?:?]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.dispatchBindingsPerType(GenericItemProvider.java:325) ~[?:?]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.addBindingConfigReader(GenericItemProvider.java:148) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_252]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_252]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_252]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_252]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod.invokeMethod(BaseMethod.java:228) ~[?:?]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod.access$500(BaseMethod.java:41) ~[?:?]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod$Resolved.invoke(BaseMethod.java:664) ~[?:?]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod.invoke(BaseMethod.java:510) ~[?:?]
	at org.apache.felix.scr.impl.inject.methods.BindMethod.invoke(BindMethod.java:42) ~[?:?]
	at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1813) ~[?:?]
	at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1788) ~[?:?]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:435) ~[?:?]
	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:325) ~[?:?]
	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:294) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1216) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1137) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:944) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:880) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1168) ~[?:?]
	at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:125) ~[?:?]
	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:920) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:469) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:487) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:1004) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.openhab.core.binding.internal.BindingConfigReaderFactory.registerDelegateService(BindingConfigReaderFactory.java:84) ~[?:?]
	at org.openhab.core.binding.internal.BindingConfigReaderFactory.addBindingConfigReader(BindingConfigReaderFactory.java:67) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_252]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_252]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_252]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_252]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod.invokeMethod(BaseMethod.java:228) ~[?:?]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod.access$500(BaseMethod.java:41) ~[?:?]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod$Resolved.invoke(BaseMethod.java:664) ~[?:?]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod.invoke(BaseMethod.java:510) ~[?:?]
	at org.apache.felix.scr.impl.inject.methods.BindMethod.invoke(BindMethod.java:42) ~[?:?]
	at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1813) ~[?:?]
	at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1788) ~[?:?]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:435) ~[?:?]
	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:325) ~[?:?]
	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:294) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1216) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1137) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:944) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:880) ~[?:?]
	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1168) ~[?:?]
	at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:125) ~[?:?]
	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:920) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:469) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:906) ~[?:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:892) ~[?:?]
	at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:128) ~[?:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:959) ~[?:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:732) ~[?:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:666) ~[?:?]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:432) ~[?:?]
	at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:665) ~[?:?]
	at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:338) ~[?:?]
	at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:382) ~[?:?]
	at org.apache.felix.scr.impl.Activator.access$200(Activator.java:49) ~[?:?]
	at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:264) ~[?:?]
	at org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196) ~[?:?]
	at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169) ~[?:?]
	at org.apache.felix.scr.impl.AbstractExtender.addingBundle(AbstractExtender.java:139) ~[?:?]
	at org.apache.felix.scr.impl.AbstractExtender.addingBundle(AbstractExtender.java:49) ~[?:?]
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:469) ~[osgi.core-6.0.0.jar:?]
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:415) ~[osgi.core-6.0.0.jar:?]
	at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) ~[osgi.core-6.0.0.jar:?]
	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) ~[osgi.core-6.0.0.jar:?]
	at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) ~[osgi.core-6.0.0.jar:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:908) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:168) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.Module.start(Module.java:467) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:468) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.ModuleContainer.start(ModuleContainer.java:750) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.ModuleContainer.applyDelta(ModuleContainer.java:741) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.ModuleContainer.resolveAndApply(ModuleContainer.java:511) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:457) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:447) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerWiring.resolveBundles(ModuleContainer.java:1313) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.resolveBundles(BundleInstallSupportImpl.java:244) ~[?:?]
	at org.apache.karaf.features.internal.service.FeaturesServiceImpl.resolveBundles(FeaturesServiceImpl.java:1168) ~[?:?]
	at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:1022) ~[?:?]
	at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1062) ~[?:?]
	at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:998) ~[?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_252]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
Caused by: org.openhab.model.item.binding.BindingConfigParseException: Could not open serial port /dev/ttyUSB0: Serial port '/dev/ttyUSB0' could not be found. Available ports are:

	at org.openhab.binding.serial.internal.SerialBinding.processBindingConfiguration(SerialBinding.java:284) ~[?:?]
	at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:53) ~[?:?]
	... 111 more

What I did:

  1. Installed openHAB in a docker container, using portainer.io (everything worked well with that)
  2. Added openhab user to dialout and tty groups on my host machine
  3. Installed Serial Binding, created .items
  4. Added EXTRA_JAVA_OPTS "-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0" to ENV in portainer
  5. Added host device /dev/ttyUSB0 to container device /dev/ttyUSB0 in portainer
  6. Rebooted and redeployed the container several times

My items file:

Switch RF_C "RF Plug C" <light> { serial="/dev/ttyUSB0@38400,ON(isFFFFFFF0FFFF\n),OFF(isFFFFFFF0FFF0\n)" }
Switch RF_D "RF Plug D" <light> { serial="/dev/ttyUSB0@38400,ON(isFFFFFFFF0FFF\n),OFF(isFFFFFFFF0FF0\n)" }

I also tried to use screen /dev/ttyUSB0 38400 both from the host and from inside the container to manually send the commands: that worked just fine and did what it was supposed to do.
From that I conclude that the docker-related part is working as expected and the problem is somehow related to openHAB.

Platform information:
Hardware: x64
OS: debian with docker
openHAB version: 2.5.6

Please feel free to reach out to me if you have any further questions! But please mind: I am a novice in terms of using docker. I installed it 3 days ago and since then successfully migrated my openHAB setup from my raspberry Pi to a docker container. Except for the Serial Binding, which does not work now.

Have you tried with just Docker or Docker compose?

I do not think openHAB is tested for Portainer compatibility. You could have a Portainer bug or incompatibility.

  • did you check if the serial device is available / listed inside of the container ? I am wondering why in the log no available serial device is being listed after the colon. This should be the case for this type of error message
  • which Java version do you use ?

Have you tried to open a shell on the running container to check /dev and permmissions of the device (if it is listed in /dev)? If not please try:

localhost:~ # docker exec -it < containername > /bin/bash
root@container:/# ls -al /dev

Replace < containername > with the string that is shown in the last column of:

localhost:~ # docker ps

Post the output of “ls -al /dev” if you’re not sure how to read it…

Hello everyone!

@Bruce_Osborne
No, until now I just used portainer to manage my Docker containers. Mainly because of ease to use and my lack of knowledge for the CLI tool.

@Wolfgang_S
I am using OpenJDK 1.8.0_252 with OpenJDK RE and 64bit Server VM Zulu 8.46.0.19-CA-linux64 build 1.8.0_252-b14.
I got these values by running java -version inside the container.

@happenpappen The command gives me the following results:

`ls -al /dev`
total 4
drwxr-xr-x 14 root root          3060 Jul 10 00:03 .
drwxr-xr-x  1 root root          4096 Jul  9 23:29 ..
crw-r--r--  1 root root     10,   235 Jul 10 00:03 autofs
drwxr-xr-x  2 root root            60 Jul 10 00:03 bsg
crw-------  1 root root     10,   234 Jul 10 00:03 btrfs-control
drwxr-xr-x  3 root root            60 Jul 10 00:03 bus
lrwxrwxrwx  1 root root            11 Jul 10 00:03 core -> /proc/kcore
drwxr-xr-x  2 root root            60 Jul 10 00:03 cpu
crw-------  1 root root     10,    62 Jul 10 00:03 cpu_dma_latency
crw-------  1 root root     10,   203 Jul 10 00:03 cuse
drwxr-xr-x  2 root root            80 Jul 10 00:03 dri
crw-------  1 root root    244,     0 Jul 10 00:03 drm_dp_aux0
lrwxrwxrwx  1 root root            13 Jul 10 00:03 fd -> /proc/self/fd
crw-rw-rw-  1 root root      1,     7 Jul 10 00:03 full
crw-rw-rw-  1 root root     10,   229 Jul 10 00:03 fuse
crw-------  1 root root     10,   228 Jul 10 00:03 hpet
crw-------  1 root root     10,   183 Jul 10 00:03 hwrng
drwxr-xr-x  2 root root           260 Jul 10 00:03 input
crw-r--r--  1 root root      1,    11 Jul 10 00:03 kmsg
crw-rw----  1 root     106  10,   232 Jul 10 00:03 kvm
crw-rw----  1 root disk     10,   237 Jul 10 00:03 loop-control
drwxr-xr-x  2 root root            60 Jul 10 00:03 mapper
crw-------  1 root root    245,     0 Jul 10 00:03 mei0
crw-r-----  1 root kmem      1,     1 Jul 10 00:03 mem
crw-------  1 root root     10,    59 Jul 10 00:03 memory_bandwidth
drwxrwxrwt  2 root root            40 Jul 10 00:03 mqueue
drwxr-xr-x  2 root root            60 Jul 10 00:03 net
crw-------  1 root root     10,    61 Jul 10 00:03 network_latency
crw-------  1 root root     10,    60 Jul 10 00:03 network_throughput
crw-rw-rw-  1 root root      1,     3 Jul 10 00:03 null
crw-r-----  1 root kmem      1,     4 Jul 10 00:03 port
crw-------  1 root root    108,     0 Jul 10 00:03 ppp
crw-------  1 root root     10,     1 Jul 10 00:03 psaux
lrwxrwxrwx  1 root root             8 Jul 10 00:03 ptmx -> pts/ptmx
drwxr-xr-x  2 root root             0 Jul 10 00:03 pts
crw-rw-rw-  1 root root      1,     8 Jul 10 00:03 random
crw-rw-r--  1 root     109  10,   242 Jul 10 00:03 rfkill
crw-------  1 root root    252,     0 Jul 10 00:03 rtc0
brw-rw----  1 root disk      8,     0 Jul 10 00:03 sda
brw-rw----  1 root disk      8,     1 Jul 10 00:03 sda1
brw-rw----  1 root disk      8,     2 Jul 10 00:03 sda2
brw-rw----  1 root disk      8,     3 Jul 10 00:03 sda3
crw-rw----  1 root disk     21,     0 Jul 10 00:03 sg0
drwxrwxrwt  2 root root            40 Jul 10 00:03 shm
crw-------  1 root root     10,   231 Jul 10 00:03 snapshot
drwxr-xr-x  2 root root           300 Jul 10 00:03 snd
lrwxrwxrwx  1 root root            15 Jul 10 00:03 stderr -> /proc/self/fd/2
lrwxrwxrwx  1 root root            15 Jul 10 00:03 stdin -> /proc/self/fd/0
lrwxrwxrwx  1 root root            15 Jul 10 00:03 stdout -> /proc/self/fd/1
crw-------  1 root root     10,   224 Jul 10 00:03 tpm0
crw-------  1 root root    246, 65536 Jul 10 00:03 tpmrm0
crw-rw-rw-  1 root root      5,     0 Jul 10 00:03 tty
crw--w----  1 root tty       4,     0 Jul 10 00:03 tty0
crw--w----  1 root tty       4,     1 Jul 10 00:03 tty1
crw--w----  1 root tty       4,    10 Jul 10 00:03 tty10
crw--w----  1 root tty       4,    11 Jul 10 00:03 tty11
crw--w----  1 root tty       4,    12 Jul 10 00:03 tty12
crw--w----  1 root tty       4,    13 Jul 10 00:03 tty13
crw--w----  1 root tty       4,    14 Jul 10 00:03 tty14
crw--w----  1 root tty       4,    15 Jul 10 00:03 tty15
crw--w----  1 root tty       4,    16 Jul 10 00:03 tty16
crw--w----  1 root tty       4,    17 Jul 10 00:03 tty17
crw--w----  1 root tty       4,    18 Jul 10 00:03 tty18
crw--w----  1 root tty       4,    19 Jul 10 00:03 tty19
crw--w----  1 root tty       4,     2 Jul 10 00:03 tty2
crw--w----  1 root tty       4,    20 Jul 10 00:03 tty20
crw--w----  1 root tty       4,    21 Jul 10 00:03 tty21
crw--w----  1 root tty       4,    22 Jul 10 00:03 tty22
crw--w----  1 root tty       4,    23 Jul 10 00:03 tty23
crw--w----  1 root tty       4,    24 Jul 10 00:03 tty24
crw--w----  1 root tty       4,    25 Jul 10 00:03 tty25
crw--w----  1 root tty       4,    26 Jul 10 00:03 tty26
crw--w----  1 root tty       4,    27 Jul 10 00:03 tty27
crw--w----  1 root tty       4,    28 Jul 10 00:03 tty28
crw--w----  1 root tty       4,    29 Jul 10 00:03 tty29
crw--w----  1 root tty       4,     3 Jul 10 00:03 tty3
crw--w----  1 root tty       4,    30 Jul 10 00:03 tty30
crw--w----  1 root tty       4,    31 Jul 10 00:03 tty31
crw--w----  1 root tty       4,    32 Jul 10 00:03 tty32
crw--w----  1 root tty       4,    33 Jul 10 00:03 tty33
crw--w----  1 root tty       4,    34 Jul 10 00:03 tty34
crw--w----  1 root tty       4,    35 Jul 10 00:03 tty35
crw--w----  1 root tty       4,    36 Jul 10 00:03 tty36
crw--w----  1 root tty       4,    37 Jul 10 00:03 tty37
crw--w----  1 root tty       4,    38 Jul 10 00:03 tty38
crw--w----  1 root tty       4,    39 Jul 10 00:03 tty39
crw--w----  1 root tty       4,     4 Jul 10 00:03 tty4
crw--w----  1 root tty       4,    40 Jul 10 00:03 tty40
crw--w----  1 root tty       4,    41 Jul 10 00:03 tty41
crw--w----  1 root tty       4,    42 Jul 10 00:03 tty42
crw--w----  1 root tty       4,    43 Jul 10 00:03 tty43
crw--w----  1 root tty       4,    44 Jul 10 00:03 tty44
crw--w----  1 root tty       4,    45 Jul 10 00:03 tty45
crw--w----  1 root tty       4,    46 Jul 10 00:03 tty46
crw--w----  1 root tty       4,    47 Jul 10 00:03 tty47
crw--w----  1 root tty       4,    48 Jul 10 00:03 tty48
crw--w----  1 root tty       4,    49 Jul 10 00:03 tty49
crw--w----  1 root tty       4,     5 Jul 10 00:03 tty5
crw--w----  1 root tty       4,    50 Jul 10 00:03 tty50
crw--w----  1 root tty       4,    51 Jul 10 00:03 tty51
crw--w----  1 root tty       4,    52 Jul 10 00:03 tty52
crw--w----  1 root tty       4,    53 Jul 10 00:03 tty53
crw--w----  1 root tty       4,    54 Jul 10 00:03 tty54
crw--w----  1 root tty       4,    55 Jul 10 00:03 tty55
crw--w----  1 root tty       4,    56 Jul 10 00:03 tty56
crw--w----  1 root tty       4,    57 Jul 10 00:03 tty57
crw--w----  1 root tty       4,    58 Jul 10 00:03 tty58
crw--w----  1 root tty       4,    59 Jul 10 00:03 tty59
crw--w----  1 root tty       4,     6 Jul 10 00:03 tty6
crw--w----  1 root tty       4,    60 Jul 10 00:03 tty60
crw--w----  1 root tty       4,    61 Jul 10 00:03 tty61
crw--w----  1 root tty       4,    62 Jul 10 00:03 tty62
crw--w----  1 root tty       4,    63 Jul 10 00:03 tty63
crw--w----  1 root tty       4,     7 Jul 10 00:03 tty7
crw--w----  1 root tty       4,     8 Jul 10 00:03 tty8
crw--w----  1 root tty       4,     9 Jul 10 00:03 tty9
crw-rw----  1 root dialout   4,    64 Jul 10 00:03 ttyS0
crw-rw----  1 root dialout   4,    65 Jul 10 00:03 ttyS1
crw-rw----  1 root dialout   4,    66 Jul 10 00:03 ttyS2
crw-rw----  1 root dialout   4,    67 Jul 10 00:03 ttyS3
crw-rw----  1 root dialout 188,     0 Jul 10 00:20 ttyUSB0
crw-------  1 root root     10,   239 Jul 10 00:03 uhid
crw-------  1 root root     10,   223 Jul 10 00:03 uinput
crw-rw-rw-  1 root root      1,     9 Jul 10 00:03 urandom
crw-rw----  1 root tty       7,     0 Jul 10 00:03 vcs
crw-rw----  1 root tty       7,     1 Jul 10 00:03 vcs1
crw-rw----  1 root tty       7,     2 Jul 10 00:03 vcs2
crw-rw----  1 root tty       7,     3 Jul 10 00:03 vcs3
crw-rw----  1 root tty       7,     4 Jul 10 00:03 vcs4
crw-rw----  1 root tty       7,     5 Jul 10 00:03 vcs5
crw-rw----  1 root tty       7,     6 Jul 10 00:03 vcs6
crw-rw----  1 root tty       7,   128 Jul 10 00:03 vcsa
crw-rw----  1 root tty       7,   129 Jul 10 00:03 vcsa1
crw-rw----  1 root tty       7,   130 Jul 10 00:03 vcsa2
crw-rw----  1 root tty       7,   131 Jul 10 00:03 vcsa3
crw-rw----  1 root tty       7,   132 Jul 10 00:03 vcsa4
crw-rw----  1 root tty       7,   133 Jul 10 00:03 vcsa5
crw-rw----  1 root tty       7,   134 Jul 10 00:03 vcsa6
crw-rw----  1 root tty       7,    64 Jul 10 00:03 vcsu
crw-rw----  1 root tty       7,    65 Jul 10 00:03 vcsu1
crw-rw----  1 root tty       7,    66 Jul 10 00:03 vcsu2
crw-rw----  1 root tty       7,    67 Jul 10 00:03 vcsu3
crw-rw----  1 root tty       7,    68 Jul 10 00:03 vcsu4
crw-rw----  1 root tty       7,    69 Jul 10 00:03 vcsu5
crw-rw----  1 root tty       7,    70 Jul 10 00:03 vcsu6
drwxr-xr-x  2 root root            60 Jul 10 00:03 vfio
crw-------  1 root root     10,    63 Jul 10 00:03 vga_arbiter
crw-------  1 root root     10,   137 Jul 10 00:03 vhci
crw-------  1 root root     10,   238 Jul 10 00:03 vhost-net
crw-------  1 root root     10,   241 Jul 10 00:03 vhost-vsock
crw-------  1 root root     10,   130 Jul 10 00:03 watchdog
crw-------  1 root root    248,     0 Jul 10 00:03 watchdog0
crw-rw-rw-  1 root root      1,     5 Jul 10 00:03 zero

ttyUSB0, to which my device is connected, is present in the container.
As said in my initial post, I am even able to use screen to successfully send commands to it.

Is the OpenHAB user a member of the dialout group? I would also check the username running the container.

Running command id inside the container gives me this:

uid=0(root) gid=0(root) groups=0(root),5(tty),20(dialout)

id openhab on my host machine results in:

uid=998(openhab) gid=997(openhab) groups=997(openhab),5(tty),20(dialout)

I configured the openHAB container via ENV parameters USER_ID 998 and GROUP_ID 997 to run as the openhab user.

Hi Marcell,

i would recommend to check if openhab ist really started with your changes to EXTRA_JAVA_OPTS. Try this inside the container:

root@container:/# ps -ef |grep java|more

and check the output.

If you get an error like “ps command not found” you may have to install the psmisc package first:

root@container:/# apt update && apt install -y psmisc

Since i don’t know on which distribution the container is based on, it might be that the package name is not “psmisc” but “ps-tools” or “ps-misc”… you have to try and find out.

kind regards,

Christoph

1 Like

Soy you using the Debian or Alpine container? I had issues with Alpine.

I’m using the debian openHAB container.
When I run ps -ef |grep java|more inside the container I get a long list which contains my EXTRA_JAVA_OPTS -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0 too.

Since you’ve verified that the device is passed to the container, the problem is almost certainly one of permissions. Unfortunately it generates the same error when the device file doesn’t exists as it does when it doesn’t have permission to open it read/write.

When you exec into the container, the user running will be root. However, the entrypoint.sh script su’s to the user openhab before starting openHAB so you need to look at the permissions os the devtty file to make sure use 998 has permission to read/write to it.

From inside the container, ls -l on the file and look at what the permissions on that file look like inside the container.

From inside the container run id openhab to see if the group memberships passed into the container correctly.

From outside the container, run ls -l on the file to make sure that user 998 has permission to read/write to it.

You are mostly going to be focusing on group permissions and membership I think.

2 Likes

What about user openhab (uid 997) in the container? you just showed root. (uid 0)

ls -l /dev/ttyUSB0 from inside the container gives me:
crw-rw---- 1 root dialout 188, 0 Jul 10 10:44 /dev/ttyUSB0

id openhab from inside the container show this:
uid=998(openhab) gid=997(openhab) groups=997(openhab),5(tty),20(dialout)

ls -l /dev/ttyUSB0 on the host returns the same as inside the container:
crw-rw---- 1 root dialout 188, 0 Jul 10 10:43 /dev/ttyUSB0

Since both inside the container and on the host openhab is member of dialout, and dialout has rw permissions to the device file, this should be correct?

1 Like

Those are correct but what about the openhab user within the container?

Isn’t this what you are asking for? @Bruce_Osborne

While almost giving up on this and searching for a different method to control my 433MHz remote plugs, I just realised that I did not reboot my host machine since installing docker on it.

So what I did was simply rebooting it, and starting up the docker containers again.

:partying_face:
Now it works like a charm! I can send serial commands from within openHAB…
Whatever the problem was, I’m very happy it is working now.
From now on, if something does not work as expected, I’ll try to reboot it first. Maybe it helps. :stuck_out_tongue_winking_eye:

Thank you very much for all of your helpful replies!

1 Like

That looks the same as outside the container posted earlier.