Symptoms & Diagnosis
When running Bluetooth-reliant applications inside a Docker container, you may encounter the “Agent registration failed” error. This typically occurs when using tools like bluetoothctl or custom BlueZ scripts to pair devices.
The primary cause is the isolation of the Docker container from the host system’s D-Bus. Since the BlueZ daemon (bluetoothd) communicates over the system bus, a containerized process cannot register an agent without a direct path to the host’s communication socket.
| Error Variant | Common Meaning |
|---|---|
| org.bluez.Error.AlreadyExists | An agent is already registered on the host or by another container. |
| Method “RegisterAgent” … doesn’t exist | The container cannot find the BlueZ interface on the D-Bus. |
| Connection refused | The D-Bus socket is not mounted or the service is down. |

Troubleshooting Guide
1. Mount the D-Bus System Socket
The most effective fix is to share the host’s D-Bus socket with the container. This allows the containerized application to talk to the BlueZ daemon directly.
docker run -it \
--net=host \
-v /var/run/dbus:/var/run/dbus \
--privileged \
your-image-name
2. Reset the Host Bluetooth Service
Sometimes the “AlreadyExists” error persists because a previous container crash left a stale registration. Restarting the BlueZ service on the host machine clears these entries.
sudo systemctl restart bluetooth
# Verify the service is active
sudo systemctl status bluetooth
3. Configure Capabilities Instead of Privileged Mode
If you prefer to avoid --privileged for security reasons, you can grant specific capabilities. The container needs NET_ADMIN to manage the Bluetooth interface.
docker run -it \
--cap-add=NET_ADMIN \
--net=host \
-v /var/run/dbus:/var/run/dbus \
your-image-name
Prevention
To prevent “Agent registration failed” in production environments, always use Docker Compose to ensure consistent volume mapping and network settings. Using network_mode: host is generally required for seamless Bluetooth agent registration.
Ensure that your containerized application handles the SIGTERM signal. If the application exits gracefully, it should unregister its agent, preventing “AlreadyExists” errors for the next container instance.
Check for conflicting agents on the host. If the host OS is already running a Bluetooth management GUI, it might claim the agent path before your Docker container has a chance to initialize.