I'm trying to give a rootless podman container access to the host bluetooth (the ultimate goal is to receive data from a heartrate sensor). My user account does not have elevated privileges. Host system uses Fedora 42, podman 5.8.1.
Containerfile
FROM fedora:latest
RUN dnf install -y \
rust \
cargo \
bluez \
bluez-libs \
dbus-devel \
dbus-tools \
dbus-daemon \
glib2-devel \
gcc \
pkg-config \
openssl-devel \
git \
procps-ng \
iproute \
shadow-utils \
&& dnf clean all
WORKDIR /app
# Handle Rootless Permissions & D-Bus Initialization
ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/var/run/dbus/system_bus_socket
ENV DBUS_SESSION_BUS_ADDRESS=unix:path=/var/run/dbus/system_bus_socket
CMD ["sh", "-c", "\
if [ ! -s /etc/machine-id ]; then dbus-uuidgen --ensure=/etc/machine-id; fi; \
echo '1. Verify socket: ls -l /var/run/dbus/system_bus_socket'; \
echo '2. Test handshake: dbus-send --system --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.Hello'; \
echo '-----------------------------'; \
exec /bin/bash"]
$ podman run -it \
--rm \
--net=host \
--privileged \
--device /dev/vhci \
--userns=keep-id \
--security-opt label=disable \
-v $(pwd):/app \
-v /var/run/dbus:/var/run/dbus:rw \
-v /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket \
app-test
Testing yields:
$ dbus-send --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.Hello
Failed to open connection to "session" message bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
I did not find much information regarding this use case. Is this something that is supported with a rootless container? Any information how to set this up correctly? Thanks.