blinkt icon indicating copy to clipboard operation
blinkt copied to clipboard

Docker blues

Open StevePoling opened this issue 5 years ago • 8 comments

The Dockerfile doesn't seem to work for me. So, I made some tweaks.

  • Changed the FROM image to balenalib/rpi-raspbian:jessie to avoid a "deprecated" message.
  • added apt-get install git
  • added git clone (this repo)
  • dropped the copy of /library and /examples

This allowed me to successfully build a docker image, but when I run it I get this unhappy message:

Traceback (most recent call last): File "larson.py", line 5, in import blinkt File "/usr/local/lib/python2.7/dist-packages/blinkt.py", line 5, in import RPi.GPIO as GPIO File "/usr/lib/python2.7/dist-packages/RPi/GPIO/init.py", line 23, in from RPi._GPIO import * RuntimeError: This module can only be run on a Raspberry Pi!

Is there something I'm missing to tell python-rpi, or docker that I'm running on an RPi4?

MacOS wouldn't let me attach my Dockerfile. So here it is inline:

FROM balenalib/rpi-raspbian:jessie RUN apt-get update -qy && apt-get install -qy
git
python
python-rpi.gpio ENTRYPOINT [] RUN git clone https://github.com/pimoroni/blinkt.git /blinkt WORKDIR /blinkt/library RUN python setup.py install WORKDIR /blinkt/examples/ CMD ["python", "larson.py"]

StevePoling avatar Aug 20 '20 21:08 StevePoling

I'm afraid the Dockerfile was contributed by @alexellis and I don't have the first clue how to get it working. I'm crossing fingers that invoking his good name will cause him to magically appear and fix all our woes, though!

Gadgetoid avatar Aug 20 '20 22:08 Gadgetoid

Hi there. I can take a look at getting this working again, but it's going to take me a few days to set up an RPi and find a Blinkt etc.

alexellis avatar Aug 21 '20 08:08 alexellis

Hi Definately not a regular docker user but I do have a Raspberry Pi 4 running Buster and Docker I did confirm that blinkt examples worked on the Pi before creating the docker image.

Note my pi user can execute docker commands $ sudo usermod -aG docker pi

Using the docker file below it worked for me.

FROM balenalib/rpi-raspbian:buster
RUN apt-get update -qy && apt-get install -qy \
git \
python \
python-rpi.gpio 
ENTRYPOINT []
RUN git clone https://github.com/pimoroni/blinkt.git /blinkt
WORKDIR /blinkt/library
RUN python setup.py install
WORKDIR /blinkt/examples/
CMD ["python", "larson.py"]

Built the container using: $ docker build -t blinkt .

Execute using: $ docker run --privileged -ti blinkt

Hope this helps.

ptbw avatar Aug 21 '20 10:08 ptbw

Thank you! This helps a lot.

The distinctions that made the difference between failing and succeeding are:

  • pull from "balenalib/rpi-raspbian:buster" not "jessie"
  • docker run --privileged ...

On Fri, Aug 21, 2020 at 6:36 AM Phil Willis [email protected] wrote:

Hi Definately not a regular docker user but I do have a Raspberry Pi 4 running Buster and Docker I did confirm that blinkt examples worked on the Pi before creating the docker image.

Note my pi user can execute docker commands $ sudo usermod -aG docker pi

Using the docker file below it worked for me.

FROM balenalib/rpi-raspbian:buster RUN apt-get update -qy && apt-get install -qy
git
python
python-rpi.gpio ENTRYPOINT [] RUN git clone https://github.com/pimoroni/blinkt.git /blinkt WORKDIR /blinkt/library RUN python setup.py install WORKDIR /blinkt/examples/ CMD ["python", "larson.py"]

Built the container using: $ docker build -t blinkt .

Execute using: $ docker run --privileged -ti blinkt

Hope this helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pimoroni/blinkt/issues/88#issuecomment-678209063, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFPNAZQHEGZTSEXTCLRQVMDSBZEZNANCNFSM4QGTC32Q .

StevePoling avatar Aug 21 '20 15:08 StevePoling

Thanks fellow Phil @ptbw 😁

So it looks like this line in the Dockerfile should be replaced?

https://github.com/pimoroni/blinkt/blob/3969699c8c72d1699c237fd80141b5c037460277/Dockerfile#L1

And also some documentation tweaks to state it should be run privileged? In fact the README.md doesn't mention Docker at all.

Gadgetoid avatar Aug 21 '20 15:08 Gadgetoid

NP. @Gadgetoid

Would you like me to create a PR to update the Dockerfile and add some instructions to the readme? (Basically expand on my comments above).

ptbw avatar Aug 21 '20 21:08 ptbw

i could do the PR write-up, i understand the problem, and what Alex did to fix it. tho i might not do as well as you. i'd feel i'm slacking if i don't at least volunteer

On Fri, Aug 21, 2020 at 5:41 PM Phil Willis [email protected] wrote:

NP. @Gadgetoid https://github.com/Gadgetoid

Would you like me to create a PR to update the Dockerfile and add some instructions to the readme? (Basically expand on my comments above).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pimoroni/blinkt/issues/88#issuecomment-678528841, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFPNAZTZHDC6Q5HJHJ66CYTSB3SZFANCNFSM4QGTC32Q .

StevePoling avatar Aug 21 '20 22:08 StevePoling

@StevePoling be my guest, expand on my comments and review the PR that included the original Dockerfile. It seems sensible to add a note about updating the image for the future.

ptbw avatar Aug 22 '20 08:08 ptbw

Note: I am deleting the Dockerfile as part of #102 since I have changed a lot of things, and don't have the ability to fix it.

Once #102 is merged I would welcome a PR re-adding it, if it's useful. With any luck there wont be another big change like this down the road.

Gadgetoid avatar Nov 02 '23 11:11 Gadgetoid

I'd support that decision :smile:

alexellis avatar Nov 10 '23 11:11 alexellis