Troubleshooting
Docker container cannot open the D-Bus socket on an edge controller
Short answer
The error names /var/run/dbus/system_bus_socket because the container's filesystem namespace does not include the host's D-Bus socket: mount that one socket only if the image needs it, or drop the dependency. The node fault is a separate local I/O fault. Prove the I/O branch, then container startup, then MQTT, in that order.
On this page
- What the D-Bus error actually tells you
- Clear the controller's I/O branch first
- Find where the data path stops
- Give the container the socket, or remove the need for it
- Worked example: ordering two faults by timestamp
- Only then test MQTT
- Change one variable at a time
- The decision, case by case
- Questions asked
Two faults are showing on the same edge controller, and they are not the same fault. The D-Bus message means your container cannot see the host's system bus socket: the container's filesystem namespace does not include /var/run/dbus/system_bus_socket, so the client fails on its first local call, typically with No such file or directory. The node fault that the controller's own I/O diagnostic tool reports is a separate fault on the local I/O branch. Work them in order: prove the I/O branch, then decide whether the container needs the bus at all, and only then test MQTT. A cold restart that clears neither is itself a finding, because faults that survive a power cycle point at configuration or hardware rather than at process timing.
What the D-Bus error actually tells you #
D-Bus is the message bus that Linux services use to talk to each other. The D-Bus convention keeps the system bus at one well-known address per host: a Unix domain socket, on a standard install /var/run/dbus/system_bus_socket, with /var/run a symlink to /run, so the same socket also answers at /run/dbus/system_bus_socket. There is no per-container bus. Any container that talks to host services shares that one socket.
A container receives its own filesystem namespace. Unless you bind-mount that socket in, the path does not exist inside the container, and the client library reports the well-known path as missing:
Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
The message names a path, but the missing thing is a mount at the container boundary, not a broken file. It is the same lesson as the Node-RED Docker EACCES mkdir: write to host storage, not container case, where the fix was to write to host storage rather than to keep chasing the path inside the container.
That reframing decides the repair. If your workload collects process data and publishes it over MQTT, it has no use for the system bus: the error is a dependency the image author built in, and removing that dependency is the cleaner fix. Mount the socket only for a container whose documented function manages host services or reacts to host events.
Clear the controller's I/O branch first #
The sudden node fault is a local fault, and no broker setting can influence it. Prove the branch before you touch Docker:
- Archive the controller application, the I/O node configuration and the container configuration using the vendor's maintenance process, before you change anything.
- Power the controller fully off, wait, and power it back on. When, as in this case, the node fault survives a cold power cycle, the fault lives in configuration, wiring or hardware, not in process timing.
- Read the complete node state in the I/O diagnostic tool. Copy the fault text, the error code with its numeric form if shown, the timestamp and the module position. If the vendor's fault-code documentation has no entry for that code, send the exact text to vendor support; an unmatched code is not a reason to reflash or downgrade.
- Hold outputs at a safe fixed state, then apply a known input at mid-scale to the analog input channel and compare the tool's reading against the application variable. Command a bounded output value next and measure what the output actually delivers.
Decision: if the node stays configured and both channels track the known values, the local branch is proven and the earlier fault was transient, so move on to the container. If the node drops out with Docker stopped and no broker reachable, stop there: the fault is in the I/O path, the module or the controller itself. When that fault follows the controller through a cold power cycle and a wiring check and support cannot clear it, the same data-collection workload runs unchanged on a fanless industrial mini PC.
Find where the data path stops #
Trace the chain from the field to the broker and back, and take one reading per segment:
| Segment | Evidence to take | Passes when | If it fails, check |
|---|---|---|---|
| Field input to controller | Tool reading while you apply a known signal | Reading tracks the signal, no node diagnostics | Field wiring, common reference, module seating, node state |
| Controller application | Published variable against the input value | Published value equals the input value | Application mapping, runtime state |
| Container startup | Container logs and process state | Process stays up and opens every local resource it requests | The D-Bus socket check below |
| Container to broker | Connection log, broker address, configured port, session state | Connection succeeds, publishes acknowledged at the configured QoS | Name resolution, routing, firewall, credentials, broker authorization |
| Application to field output | Commanded value against measured output | Measured output follows the command | Output mapping, node diagnostics, field load |
Decision: fix your attention on the last point where valid data exists. Everything upstream of it is proven; everything downstream is unproven. In this case the chain dies at container startup, so the broker was never reached and was never guilty.
Give the container the socket, or remove the need for it #
Sort the error by what the container actually sees:
No such file or directoryat the socket path: the namespace has no mount. This is the failure in this case. Read the image's documentation for a declared D-Bus requirement before mounting anything.- Path present, permission denied: the container's process user lacks rights on the socket. Run the container with the host group that owns the socket, with matching identifiers.
- Path present, connection refused: something answers at the path but no healthy bus is behind it. Check the bus service on the controller itself and its logs.
- Error appears only with one image or one firmware release: suspect packaging or a compatibility break. Change one of the two per test and hold the other fixed.
When the need is real, mount the single socket file, and in a multi-container setup grant it to the one service that requires it:
services:
collector:
volumes:
- /run/dbus/system_bus_socket:/run/dbus/system_bus_socket
Understand what the mount gives away. The bus judges a connecting process by its user identity, not by the container it lives in, so a container holding the system bus socket can call every bus service that policy allows for that user, including host service management. That is privileged host access on a plant controller.
If some function of yours genuinely manages host services, ask whether that function belongs on the host rather than in a container; it is the same boundary decision as Rebooting the host PC from Node-RED running in a container. If the client must find the socket at a different path inside the container, the D-Bus libraries honor the DBUS_SYSTEM_BUS_ADDRESS environment variable, so point it at the mounted path instead of remounting half the host. And if the container exits outright rather than staying up, walk the exit with the checklist for resolving Docker container exits on a PFC200 controller; the same exit path applies to any Linux edge controller.
Decision: mount a documented need, mount the one socket, grant it to the one service. Otherwise strip the bus dependency from the image.
Worked example: ordering two faults by timestamp #
Timestamps decide causality, and you can read controller, container and broker logs against one clock, because a container runs on the host clock rather than keeping its own, as set out in Node-RED in Docker uses the host clock, not its own time. Take these illustrative timestamps, structured the way you should read your own restart cycle:
- 08:10:00 — the container starts.
- 08:10:02 — the socket error is logged, 2 s after start.
- 08:10:03 — the process exits; nothing has left the container over the network.
- 08:14:41 — the I/O tool first reports the node fault. 08:14:41 minus 08:10:03 is 4 min 38 s, that is 278 s after the container had already exited.
- Broker log, 08:10:00 to 08:15:00 — 0 connection attempts from the controller's address.
The arithmetic gives two decisions. A cause cannot follow its effect, and the container was gone 278 s before the node fault appeared, so the container did not cause the node fault. And 0 attempts at the broker proves the MQTT failure never left the container: the process died at local startup, before any connection could be attempted. Two independent faults; repair them in the order I/O branch, container mount, then broker.
Only then test MQTT #
With the container staying up and the local error gone, work the network path in this order:
- Take the broker address and port from your own configuration, not from a remembered default.
- Resolve the broker name and open TCP to the configured port. A timeout points at routing, interface state or a firewall on the path; a refusal points at the broker's listening address and port.
- Bring up the session: client identity, credentials, protocol settings, then broker authorization.
- Publish a known process value and confirm the acknowledgement at the configured QoS, then confirm the value arrives where the subscriber reads it.
If the container is up and the broker still never answers, the failure has moved into the class covered by Node-RED MQTT stuck on connecting inside a Docker container, and that checklist applies directly. Decision: an acknowledged publish with the correct value end to end closes the case. If the broker holds the right value but the field output is wrong, go back to the application mapping and the I/O branch, not to MQTT.
Change one variable at a time #
Before any change, record the controller firmware version, the container image identifier, its mounts, its environment settings and the complete error text, and store them with the backup. Then change exactly one thing per test — the image, the mount or the firmware — and repeat the same three checks after each change: node state, container startup, one MQTT publish.
Stepping the firmware back a release, or running the fieldbus daemon as its own container instead of inside the application container, are architecture changes worth testing when a failure tracks a firmware update. Neither is a confirmed repair for your installation, and a downgrade needs the vendor-documented pairing of firmware and image for your exact controller. Keep a change only when the socket error clears, no new node diagnostics appear, and the analog values still track the known inputs.
The decision, case by case #
- Node fault survives a cold power cycle: local I/O-branch fault. Back up, capture the exact unmatched error code, send it to vendor support, and test the branch with known signals while outputs are held safe. Docker and broker settings cannot fix it.
- Container reports the D-Bus socket missing: the namespace lacks the mount. Mount the single socket only if the image documents the need, otherwise remove the bus dependency from the image, and treat any mounted socket as privileged host access.
- Container up but MQTT silent: network path. Work broker address and port, session and authorization in that order, and confirm with a known value and an acknowledgement.
Questions asked
Why does the container report No such file or directory for the D-Bus socket?
Because the socket is not in the container's filesystem namespace at all. Unless the host path is bind-mounted in, the client library finds nothing at the well-known location and reports the path as missing. The repair is a mount decision, not a file repair: add the socket only when the image documents that it needs host D-Bus, and otherwise remove the image's dependency on the bus, which is the cleaner choice for a headless data collector.
Is it safe to mount the host D-Bus socket into a container?
Treat it as privileged host access. On a plant network the safer design is an image without the bus dependency; when the mount is unavoidable, grant it to the one service that needs it and record it.
Can I mount the whole /run directory instead of the single socket file?
No. A single socket mount keeps the exposure limited to the bus, while a broad mount of /run also hands the container other host sockets and runtime state it has no use for. Mount exactly the path the image documents. If the client looks under the /run path, remember that /var/run and /run are the same location on current distributions.
The I/O tool reports the node not configured and the error code matches nothing in the vendor's documentation. What now?
Record the exact text, the numeric code if one is shown, the timestamp and the module position, and archive a backup before changing anything. An unmatched code is not a reason to reflash or downgrade. Send the exact code to the controller vendor's support channel and treat the fault, meanwhile, as a local I/O branch problem that Docker and broker settings cannot influence.
Do I need to align clocks before comparing controller and container logs?
No correction is needed between the two, because a container runs on the host clock rather than keeping its own. Put the controller itself on a common time source with the broker first, and then event ordering and intervals, such as the gap between a container exit and a node fault, can be read straight from the logs.