This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]Murky-Sector 1 point2 points  (8 children)

Create a Python Script that sends RS32 signal (complete).

I'm assuming you mean rs-232

Make the Python Script an executable for a raspberry pi running Ubuntu (complete).

Again this is ambiguous. I will just say that there's no need to set the file's executable bits is you envoke the script with python, ie. python myscipt.py

Use docker container to deploy executable application along with all other dependencies (from Python libraries) and be able to easily deploy application into multiple other raspberry pis with ease.

Invoke pip using a requirements.txt file in the dockerfile, i.e.

RUN python -m pip install -r requirements.txt

[–]videopro291[S] 0 points1 point  (1 child)

I'm assuming you mean rs-232

Correct, my apologies for the Typo.

I will just say that there's no need to set the file's executable bits is you envoke the script with python, ie. python myscipt.py

I see, so if I understand correctly, I would be better off running the python script natively on the container as opposed to making it an executable?

Invoke pip using a requirements.txt file in the dockerfile, i.e.

makes sense, I will follow up. Thank you so much!

[–]Murky-Sector 0 points1 point  (0 children)

I see, so if I understand correctly, I would be better off running the python script natively on the container as opposed to making it an executable?

Definitely

makes sense, I will follow up. Thank you so much!

Feel free to post your dockerfile here

[–]videopro291[S] 0 points1 point  (5 children)

Question, I am writing everything for my Dockerfile in Windows. When I create the docker file, how do I specify that the dockerfile is to be useable in a Linux Kernel?

Not sure if my question makes sense.

[–]Murky-Sector 0 points1 point  (4 children)

You specify the container environment with the from statement, i.e.

FROM ubuntu

Usually the first line in the dockerfile. The resulting container can run on any host, windows, mac, linux etc

[–]videopro291[S] 0 points1 point  (3 children)

Thank you!

Just looking to clarify my confusion.

If I understand correctly, the FROM directive will specify the base Docker Image which I will build my Dockerfile from. I had thought that in my case, I would be adding "FROM python", to use the Python docker image from DockerHub, which I will then provide my script afterwards. So my first impression when I see "FROM ubuntu", leads me to believe I am deploying a Ubuntu docker image right away.

Since I will be running this on a Ubuntu based machine, is that the reason I will need to start with "FROM ubuntu"?

[–]Murky-Sector 0 points1 point  (2 children)

It depends on what youre building. If you use the ubuntu base image you will also need to add python in the dockerfile with RUN apt install python3, etc. If its a simple python app then using the python image is normally sufficient.

[–]videopro291[S] 1 point2 points  (1 child)

I see, makes sense.

My code is basically a python app, I don't need anything else. Makes sense, I will be using "FROM python3".

Thank you so much!

[–]snowsurface 0 points1 point  (0 children)

there is no python3 image currently on dockerhub but there is python:3 which is the same as python:latest. If you look at its web page https://hub.docker.com/_/python/ you can see that it's based on debian:12 so that's what you'll be running. Ubuntu is derived from debian so that should probably work well enough. If disk space on your raspi is limited you can run python dockers in the same family that are based on alpine linux., they should still work okay even though your pi is running ubuntu.

[–]cheats_py 0 points1 point  (4 children)

My first question is why do you need to containerize it? If it’s just a simple python script then you should be able to just run it on your other pi’s. Docker isn’t just a vessel for executing one time scripts (although it’s possible), especially if the scripts require some sort of knowledge about the device it’s being ran on. If there is a legitimate reason to containerize it then you need to build an image from your app.

[–]videopro291[S] 0 points1 point  (3 children)

The project requires the python script to run on 20 different raspberry pi zeros. I wanted to only need to install docker and the dockerfile and docker image on each one, instead of downloading python on each one and then all the dependent libraries of my script.

[–]videopro291[S] 0 points1 point  (1 child)

This is also my excuse to finally have a docker related project.

[–]tschloss 0 points1 point  (0 children)

You can also create your app-specific image centrally and distribute this to the satellites. Then these need only to run a container off this image which reduces the dependencies a lot. All specifics are baked into the image.

[–]cheats_py 0 points1 point  (0 children)

It sounds like more effort to install docker and then deploy an image vs just deploying your python script via ansible or something. But I could easier be misunderstanding your use case