[docker] Serial port '/dev/xxxxx' could not be opened

I am testing docker to run openHAB in a container.
So far it seems to work great.

Now I included my Enocean-USB-device.

  --device "/dev/ttyUSB-Enocean01" \
  --env EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB-Enocean01" \

When I docker runmy setup it works as expected.
The Enocean items work and change state when I press a Enocean button.

But when I docker restart openhab I get this errors.

2018-09-15 21:06:41.878 [ERROR] [org.apache.felix.configadmin        ] - [org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService, id=419, bundle=236/mvn:org.openhab.binding/org.openhab.binding.enocean/1.13.0-SNAPSH│
or│OT]: Updating property serialPort of configuration org.openhab.enocean caused a problem: Serial port '/dev/ttyUSB-Enocean01' could not be opened. Available ports are:                                                                 │
  │org.osgi.service.cm.ConfigurationException: serialPort : Serial port '/dev/ttyUSB-Enocean01' could not be opened. Available ports are:                                                                                                 │
  │        at org.openhab.binding.enocean.internal.bus.EnoceanBinding.updated(EnoceanBinding.java:159) ~[?:?]                                                                                                                             │
  │        at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189) ~[9:org.apache.felix.configadmin:1.9.4]                                                                                       │
  │        at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152) [9:org.apache.felix.configadmin:1.9.4]                                                                                  │
  │        at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85) [9:org.apache.felix.configadmin:1.9.4]                                                                            │
  │        at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1102) [9:org.apache.felix.configadmin:1.9.4]                                                                           │
  │        at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1058) [9:org.apache.felix.configadmin:1.9.4]                                                                               │
  │        at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:138) [9:org.apache.felix.configadmin:1.9.4]                                                                                                                    │
  │        at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:105) [9:org.apache.felix.configadmin:1.9.4]                                                                                                                     │
20│        at java.lang.Thread.run(Thread.java:748) [?:?]                                                                                       

removing the container and docker runagain with the same config it works again.

I can reproduce this behavior.
An I missing something?
Why does restarting the container not work, but rerunning it does?

I also get this errors when restarting.

2018-09-15 21:06:34.361 [WARN ] [ig.xml.osgi.XmlDocumentBundleTracker] - The XML document '/ESH-INF/thing/whitelight.xml' in module 'org.eclipse.smarthome.binding.lifx' could not be parsed: The XmlConfigDescriptionProvider must not
 be null!                                                                                                                                                                                                                              
java.lang.IllegalArgumentException: The XmlConfigDescriptionProvider must not be null!                                                                                                                                                 
        at org.eclipse.smarthome.core.thing.xml.internal.ThingTypeXmlProvider.<init>(ThingTypeXmlProvider.java:81) ~[?:?]                                                                                                              
        at org.eclipse.smarthome.core.thing.xml.internal.XmlThingTypeProvider.createDocumentProvider(XmlThingTypeProvider.java:163) ~[?:?]                                                                                             
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.acquireXmlDocumentProvider(XmlDocumentBundleTracker.java:180) ~[99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                     
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.addingObject(XmlDocumentBundleTracker.java:205) ~[99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                   
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.parseDocuments(XmlDocumentBundleTracker.java:351) [99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                  
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.processBundle(XmlDocumentBundleTracker.java:337) [99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                   
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.access$4(XmlDocumentBundleTracker.java:332) [99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                        
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker$2.run(XmlDocumentBundleTracker.java:307) [99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                           
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]                                                                                                                                               
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]                                                                                                                                                              
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]                                                                                                 
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]                                                                                                        
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]                                                                                                                                       
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]                                                                                                                                       
        at java.lang.Thread.run(Thread.java:748) [?:?]                                                                                                                                                                                 
2018-09-15 21:06:34.363 [WARN ] [ig.xml.osgi.XmlDocumentBundleTracker] - The XML document '/ESH-INF/thing/bridge-types.xml' in module 'org.openhab.binding.avmfritz' could not be parsed: The XmlConfigDescriptionProvider must not be 
null!                                                                                                                                                                                                                                  
java.lang.IllegalArgumentException: The XmlConfigDescriptionProvider must not be null!                                                                                                                                                 
        at org.eclipse.smarthome.core.thing.xml.internal.ThingTypeXmlProvider.<init>(ThingTypeXmlProvider.java:81) ~[?:?]                                                                                                              
        at org.eclipse.smarthome.core.thing.xml.internal.XmlThingTypeProvider.createDocumentProvider(XmlThingTypeProvider.java:163) ~[?:?]                                                                                             
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.acquireXmlDocumentProvider(XmlDocumentBundleTracker.java:180) ~[99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                     
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.addingObject(XmlDocumentBundleTracker.java:205) ~[99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                   
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.parseDocuments(XmlDocumentBundleTracker.java:351) [99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                  
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.processBundle(XmlDocumentBundleTracker.java:337) [99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                   
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.access$4(XmlDocumentBundleTracker.java:332) [99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                        
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker$2.run(XmlDocumentBundleTracker.java:307) [99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                           
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]                                                                                                                                               
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]                                                                                                                                                              
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]                                                                                                 
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]                                                                                                        
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]                                                                                                                                       
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]                                                                                                                                       
        at java.lang.Thread.run(Thread.java:748) [?:?]                                                                                                                                                                                 
2018-09-15 21:06:34.362 [WARN ] [ig.xml.osgi.XmlDocumentBundleTracker] - The XML document '/ESH-INF/thing/thing-types.xml' in module 'org.openhab.binding.harmonyhub' could not be parsed: The XmlConfigDescriptionProvider must not be
 null!                                                                                                                                                                                                                                 
java.lang.IllegalArgumentException: The XmlConfigDescriptionProvider must not be null!                                                                                                                                                 
        at org.eclipse.smarthome.core.thing.xml.internal.ThingTypeXmlProvider.<init>(ThingTypeXmlProvider.java:81) ~[?:?]                                                                                                              
        at org.eclipse.smarthome.core.thing.xml.internal.XmlThingTypeProvider.createDocumentProvider(XmlThingTypeProvider.java:163) ~[?:?]                                                                                             
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.acquireXmlDocumentProvider(XmlDocumentBundleTracker.java:180) ~[99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                     
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.addingObject(XmlDocumentBundleTracker.java:205) ~[99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                   
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.parseDocuments(XmlDocumentBundleTracker.java:351) [99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                  
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.processBundle(XmlDocumentBundleTracker.java:337) [99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                   
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.access$4(XmlDocumentBundleTracker.java:332) [99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                        
        at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker$2.run(XmlDocumentBundleTracker.java:307) [99:org.eclipse.smarthome.config.xml:0.10.0.201809111909]                                                           
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]                                                                                                                                               
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]                                                                                                                                                              
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]                                                                                                 
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]                                                                                                        
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]                                                                                                                                       
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]                                                                                                                                       
        at java.lang.Thread.run(Thread.java:748) [?:?]                                                                                                                                                                                 

But this may be another issue.

My guess is, it could have something to do with openhab not shutting down gracefully.
At least I see no Stopping entries in the logs when restarting or stopping the container.

Have you tried passing in the raw path to the device instead of the symbolic link? Maybe the container has a problem with that.

As for why a restart of the container doesn’t work but recreating a new container works, it probably has to do with a lock file that doesn’t get properly cleaned up on the container restart so when the container comes back up it things the device is already locked so OH can’t open it.

That’s just a guess though. You might google around and search the Docker forums to see if you can find someone having a similar problem when passing devices into the container.

You are right.

root@openhab-test:/openhab# ls -al /var/lock/
insgesamt 12
drwxrwxrwt 1 root    root    4096 Sep 17 18:57 .
drwxr-xr-x 1 root    root    4096 Aug 21 11:49 ..
-rw-r--r-- 1 openhab openhab   11 Sep 16 00:45 LCK..ttyUSB-Enocean01

There is a lock file created when running the container.
When I restart the container. The old lock file still exists.
Deleting the lock file and restarting the container works.

So the question is:
Whos fault is it that the lock file is not deleted when the container is stopped?

According to https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/ the root process inside the container should get SIGTERM when the container gets stopped.

But I cannot see if this is the case or what the root processactually is.

Neither docker logs -f openhab-test nor the log files show any sign of a stopping process.

When I docker exec -it openhab-test /bin/bash inside the container the is no ps command to see the running processes.

I think that is as far as I can investigate.

I’m not really sure who creates and enforces the lock file but I think it’s the root OS, not OH, though the fact that the file is owned by openhab:openhab implies otherwise.

You can see the running processes outside of the container.

This is the result of running top on my host. PID 11699 is OH running inside a container. I pass two devices into my container and I’ve not encountered this problem before. Are you running a snapshot?

OK, got to a computer and I just did a restart of my container, first one since upgrading to the latest snapshot, and I have the same error.

I’ll file an issue on the Docker repo.

1 Like

This will be fixed in the next ESH stable.