Docker container - DBus issues

I built a docker-image based on https://github.com/nymea/nymea-docker.
For making it work on Synology NAS, a little change was necessary, because of an error about missing shared library libQt5Core.so.5. See fix libQt5Core.so.5 not found error · luksus42/nymea-docker@3855ccc · GitHub

(In general, it needs to be run with --privileged flag)

Besides this, the nymea-core system gets started and can be accessed, but it throws a lot of errors about DBus, where nothin gis connected and nothing can be registered.
Here is the startup log (Hostmachine is amd64, manjaro linux, on synology it’s similar):

 I | Application: =====================================
 I | Application: nymead 1.5.0+202210250236~buster1 started as root.
 I | Application: =====================================
 W | Platform: DBus call to logind failed: "org.freedesktop.DBus.Error.Disconnected" "Not connected to D-Bus server"
 W | DBus: Failed to register D-Bus service.
 W | Configuration: No TCP server configuration found. Generating default of nymeas://0.0.0.0:2222
 W | Configuration: No Web server configuration found. Generating defaults of http://0.0.0.0:80 and https://0.0.0.0:443
 W | Configuration: No WebSocket server configuration found. Generating default of wss://0.0.0.0:4444
 W | Configuration: No MQTT server configuration found. Generating default of 0.0.0.0:1883
 W | Platform: Error setting time zone: "org.freedesktop.DBus.Error.Disconnected" "Not connected to D-Bus server"
 I | UserManager: Successfully initialized user database.
 W | DBus: Failed to register D-Bus service.
 W | UserManager: Failed to register PushButton D-Bus service.
 W | ServerManager: Could not load certificate key file "/var/lib/nymea/certs/nymead-certificate.key" because the file does not exist.
 W | ServerManager: Using newly created self-signed SSL certificate: "/var/lib/nymea/certs/nymead-certificate.crt"
*** WARNING *** The program 'nymead' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
 W | PlatformZeroConf: Failed to register ZeroConf service "nymea-tcp-default" with dns_sd. Error: -65537
 W | ServerManager: Could not register ZeroConf service for ServerConfiguration("0.0.0.0", "default", "0.0.0.0:2222") 
 W | PlatformZeroConf: Failed to register ZeroConf service "nymea-ws-default" with dns_sd. Error: -65537
 W | ServerManager: Could not register ZeroConf service for ServerConfiguration("0.0.0.0", "default", "0.0.0.0:4444") 
 W | default: Cannot find a running Bluez. Please check the Bluez installation.
 W | PlatformZeroConf: Failed to register ZeroConf service "nymea-http-secure" with dns_sd. Error: -65537
 W | ServerManager: Could not register ZeroConf service for ServerConfiguration("0.0.0.0", "secure", "0.0.0.0:443") 
 W | PlatformZeroConf: Failed to register ZeroConf service "nymea-http-insecure" with dns_sd. Error: -65537
 W | ServerManager: Could not register ZeroConf service for ServerConfiguration("0.0.0.0", "insecure", "0.0.0.0:80") 
 W | PlatformZeroConf: Failed to register ZeroConf service "nymea-mqtt-default" with dns_sd. Error: -65537
 W | ServerManager: Could not register ZeroConf service for ServerConfiguration("0.0.0.0", "default", "0.0.0.0:1883") 
 W | DBus: Failed to register D-Bus service.
 W | DBus: Failed to register D-Bus service.
 W | DBus: Failed to register D-Bus service.
 W | DBus: Failed to register D-Bus service.
 W | DBus: Failed to register D-Bus service.
 W | Bluetooth: No bluetooth adapter found. Resource not available.
 W | DBus: Failed to register D-Bus service.
 W | DBus: Failed to register D-Bus service.
 W | DBus: Failed to register D-Bus service.
 W | DBus: Failed to register D-Bus service.
 I | MacAddressDatabase: Database initialized successfully "/usr/share/nymea/nymead/mac-addresses.db"
 I | NetworkDeviceDiscovery: Created successfully
 I | NetworkDeviceDiscovery: Loading cached network device information from "/var/cache/nymea/network-device-discovery.cache"
 I | NetworkDeviceDiscovery: Loaded 0 network device infos from cache.
 W | DBus: Failed to register D-Bus service.
 W | NetworkManager: System DBus not connected. NetworkManager not available.
 W | PlatformZeroConf: Failed to create service browser: -65537
 W | PlatformZeroConf: The Bonjour plugin does not support browsing all services. You must specify a serviceType.
 W | PlatformZeroConf: Failed to create service browser: -65537
 W | PlatformZeroConf: Failed to create service browser: -65537
 W | PlatformZeroConf: Failed to create service browser: -65537
 W | PlatformZeroConf: Failed to create service browser: -65537
 W | PlatformZeroConf: Failed to create service browser: -65537
 W | PlatformZeroConf: Failed to create service browser: -65537
 W | Bluez: System DBus not connected.
 W | Nuki: Bluetooth not available
 W | PlatformZeroConf: Failed to create service browser: -65537
 W | PlatformZeroConf: Failed to create service browser: -65537
 I | Shelly: Joined CoIoT multicast group
 W | PlatformZeroConf: Failed to create service browser: -65537

As a result of this, for example there are no editable network-settings, time(-zone) cannot be changed/saved and the system does not seem to have internet access.

So I wonder, how we could get DBus/systemd up and running within the container.
There are several infos how this could be solved, like here docs/centos at master · docker-library/docs · GitHub, but it did not work out for me yet.

Hey @luksus42 , thanks for looking into this, much appreciated!

While I can’t answer all the questions, I can try to help as much as possible.

  • the libQtCore issue: While your patch may make it work, this looks somewhat dangerous that nymea may crash at some point later. I think way to go is to compare the Qt version that is installed in the container with the version that has been used to build nymea. Seeing that this is a buster build of nymea (perhaps you want to move to bullseye) I think the cause may be that we’re shipping an updated Qt version in the nymea repository because the one coming with buster has a bug in SSL. So my suggestion would be to move the docker container to bullseye. If you want to stick with manjaro you should probably use an ubuntu built package of nymea instead. In any case, the used system needs to line up the build of the nymea packages.

  • D-Bus… Now this seems docker specific… I am not totally experienced with docker but afaik, the main difference to other container systems is that it would only run the single process (as opposed to an entire init). This would result in no dbus running indeed. I suppose it’d be worth a try to run a dbus session inside the container. I suspect network configuration would still not work, but then, do you really want to configure the network on your NAS with nymea? The most useful thing on dbus would be to also launch packagekit over dbus to allow installing nymea plugins in the container. Perhaps something like this may be of help: Run dbus-daemon inside Docker container - Stack Overflow

  • Internet access: This is most likely not related to dbus at all but probably some docker configuration is required to forward the network. However, I wonder why you say it has no internet access. If you can connect to it using nymea:app, that seems to be working, no?

oh, another note: for some reason it seems to install nymea-zeroconf-plugin-dnssd, you probably want to use nymea-zeroconf-plugin-avahi instead. And then the docker config will need to be patched to allow the container accessing the avahi socket.

Youre right, there is internet access.
It was just assumption by me, because the system time could not be updated and no network-manager was present.
But I can for example add the OpenWeatherMap thing and it works.

I will do further test, based on your ideas.