Python and Raspbian Stretch Docker Image

Hey guys, I’m trying to get Bluez to work with my resinio with a Python3 app ; I can’t get Bluez 5.23 to work so i have hope using later versions (5.48) which is only available in the Stretch repos. I’m using the resin/raspberrypi3-python:3 image which is based on Raspbian Jessie. Is there a way to have a Python Docker image that uses Raspbian Stretch ? I’ve tried to use resin/raspeberrypi3-debian:stretch and install Python3 inside, but I get weird errors with resin (Failed to install release agent and a bunch of other stuff) and my python local import won’t work when they do work with the proper docker image.
Thanks for the help,
Alex

hey @Shad , that is very strange. Do you install python3 in the debian stretch image? also could you post your Dockerfile here where you get the strange errors and we can try figure out what is going on. I would expect it to work fairly easily.

Here’s the DockerFile :

FROM resin/%%RESIN_MACHINE_NAME%%-debian:stretch
WORKDIR /usr/src/app
ENV INITSYSTEM on
COPY ./requirements.txt ./requirements.txt
RUN apt-get update && apt-get install -y \
  hostapd dhcpcd5 dnsmasq \
  darkice icecast2 curl haveged rfkill \
  pulseaudio pulseaudio-module-bluetooth bluez bluez-firmware vlc\
  libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev\
  python3 python3-dev python3-pip python3-setuptools python3-wheel\
  && adduser --disabled-password --gecos "" ices\
  && adduser ices pulse-access \
  && mkdir /usr/local/icecast \
  && mkdir /usr/local/icecast/logs \
  && touch /usr/local/icecast/logs/error.log \
  && touch /usr/local/icecast/logs/access.log \
  && chown ices /usr/local/icecast/logs/error.log \
  && chown ices /usr/local/icecast/logs/access.log \
  && pip3 install -r ./requirements.txt \
  && bluetoothctl --version
COPY . ./
ENV INITSYSTEM on
CMD ["python3", "Octave/main.py"]

and here are the logs:

 30.08.18 11:36:22 (+0200) Started service 'main sha256:86b7776d876df24ebaeda81fae0c616e8922fc684849e9bd895395a26e2119a4'
30.08.18 11:36:23 (+0200)  main  Systemd init system enabled.
30.08.18 11:36:23 (+0200)  main  systemd 232 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD+IDN)
30.08.18 11:36:23 (+0200)  main  Detected virtualization docker.
30.08.18 11:36:23 (+0200)  main  Detected architecture arm.
30.08.18 11:36:23 (+0200)  main  Set hostname to <643e542>.
30.08.18 11:36:23 (+0200)  main  Failed to install release agent, ignoring: No such file or directory
30.08.18 11:36:23 (+0200)  main  systemd-remount-fs.service: Cannot add dependency job, ignoring: Unitsystemd-remount-fs.service is masked.
30.08.18 11:36:23 (+0200)  main  kmod-static-nodes.service: Cannot add dependency job, ignoring: Unit kmod-static-nodes.service is masked.
30.08.18 11:36:23 (+0200)  main  sys-fs-fuse-connections.mount: Cannot add dependency job, ignoring: Unit sys-fs-fuse-connections.mount is masked.
30.08.18 11:36:23 (+0200)  main  dev-hugepages.mount: Cannot add dependency job, ignoring: Unit dev-hugepages.mount is masked.
30.08.18 11:36:23 (+0200)  main  sys-kernel-config.mount: Cannot add dependency job, ignoring: Unit sys-kernel-config.mount is masked.
30.08.18 11:36:23 (+0200)  main  systemd-logind.service: Cannot add dependency job, ignoring: Unit systemd-logind.service is masked.
30.08.18 11:36:23 (+0200)  main  getty.target: Cannot add dependency job, ignoring: Unit getty.target is masked.
30.08.18 11:36:23 (+0200)  main  display-manager.service: Cannot add dependency job, ignoring: Unit display-manager.service is masked.
30.08.18 11:36:26 (+0200)  main  Traceback (most recent call last):
30.08.18 11:36:26 (+0200)  main    File "Octave/main.py", line 4, in <module>
30.08.18 11:36:26 (+0200)  main      from Octave.httpfs import Httpfs
30.08.18 11:36:26 (+0200)  main  ImportError: No module named 'Octave'

I still could log in the docker, BlueZ version was as expected 5.43 but i couldn’t use it, here are the bluetoothd service logs:

Aug 30 09:36:26 643e542 systemd[1]: Starting Bluetooth service...
Aug 30 09:36:27 643e542 bluetoothd[189]: Bluetooth daemon 5.43
Aug 30 09:36:27 643e542 systemd[1]: Started Bluetooth service.
Aug 30 09:36:27 643e542 bluetoothd[189]: Starting SDP server
Aug 30 09:36:27 643e542 bluetoothd[189]: binding L2CAP socket: Address already in use
Aug 30 09:36:27 643e542 bluetoothd[189]: Server initialization failed
Aug 30 09:36:27 643e542 bluetoothd[189]: Bluetooth management interface 1.14 initialized
Aug 30 09:36:27 643e542 bluetoothd[189]: Failed to start listening: l2cap_bind: Address already in use
Aug 30 09:36:27 643e542 bluetoothd[189]: Failed to create GATT database for adapter
Aug 30 09:36:27 643e542 bluetoothd[189]: Unable to register new adapter

I don’t know if its related to resin’s release agent, but at least with BlueZ 5.23 on Raspbian Jessie i could get an adapter and try to do things with bluetoothctl, even if it would ignore the /etc/bluetooth/main.conf file.
I hope this helps,

Hi,

I’m pretty sure that all these warnings are not related as they complains about some masked services.They were masked in purpose since we don’t want them to run in the container.

30.08.18 11:36:23 (+0200)  main  Failed to install release agent, ignoring: No such file or directory
30.08.18 11:36:23 (+0200)  main  systemd-remount-fs.service: Cannot add dependency job, ignoring: Unitsystemd-remount-fs.service is masked.
30.08.18 11:36:23 (+0200)  main  kmod-static-nodes.service: Cannot add dependency job, ignoring: Unit kmod-static-nodes.service is masked.
30.08.18 11:36:23 (+0200)  main  sys-fs-fuse-connections.mount: Cannot add dependency job, ignoring: Unit sys-fs-fuse-connections.mount is masked.
30.08.18 11:36:23 (+0200)  main  dev-hugepages.mount: Cannot add dependency job, ignoring: Unit dev-hugepages.mount is masked.
30.08.18 11:36:23 (+0200)  main  sys-kernel-config.mount: Cannot add dependency job, ignoring: Unit sys-kernel-config.mount is masked.
30.08.18 11:36:23 (+0200)  main  systemd-logind.service: Cannot add dependency job, ignoring: Unit systemd-logind.service is masked.
30.08.18 11:36:23 (+0200)  main  getty.target: Cannot add dependency job, ignoring: Unit getty.target is masked.
30.08.18 11:36:23 (+0200)  main  display-manager.service: Cannot add dependency job, ignoring: Unit display-manager.service is masked.

the local import issue seems weird, let me try to replicate it.