• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Application developed with commercial Raspberry Pi
Dear Armin,

I think this information likely explained somewhere but could you please let me know again?

Can I run an application developed with commercial (standard) Raspberry Pi, on netPI without changing it at all?
If so, I would like to know its procedure, please.

If my application is made in Python, I guess that I should install Docker on the Rapsberry Pi, create a container where the Python program runs, and load this image onto netPI.
But, I am not 100% sure, which procedure is a normal way.
I guess it may be a normal procedure to use a bare metal model of netPI and copy all Raspberry's environment to netPI.

Moreover, if I want to use the DI/DO extension (NIOT-E-NPIX-4DI4DO) for my own container, I can't imagine how to develop it.

Thank you very much for your information.
Best regards,
The procedure is as follows:

1. Install Raspbian OS on your RPi SD card
2. Install Docker on your RPi as described here https://www.raspberrypi.org/blog/docker-...pberry-pi/
3. Now you have two methods to build a container image
  1. Build an image based on a script file named by default Dockerfile. Command reference of Dockerfile is here https://www.raspberrypi.org/blog/docker-...pberry-pi/. Hilscher uses this method always since the script file is constant and the resulting Docker container is always the same. Here is an example of a Dockerfile of HDMI container: https://github.com/HilscherAutomation/ne...Dockerfile
  2. Or you do manually
4. If then finally your container image is ready on your commcercial RPi then you need to make it accessible for other Docker hosts like netPI on a Docker Registry which is more or less just a big database full of containers. You can have
  1. your own registry on a local Linux server (like a commercial Raspberry Pi also) running, so not everybody can access it. I described how to make an own registry server here https://forum.hilscher.com/Thread-Setup-...containers
  2. or you use an Internet Docker Registry like Docker Hub at https://hub.docker.com/. This is how Hilscher is doing it. So create an account there and you can push container images onto Docker Hub for free if they are public. This is how Hilscher is doing it at https://hub.docker.com/u/hilschernetpi repository.
5. Once you uploaded your container on either registry with command "docker push <container-name>" all others that have access to this registry can pull it later from there. So as with the netPI example container images I pushed them all on Docker hub and others like you can pull it from there

I always recommend to use Dockerfile based build process. Once you have the Dockerfile ready just call in this folder "docker build -t thisismyfirstcontainer:1.0 ." to start building process. You can try loading a Dockerfile from the web like this one here https://github.com/HilscherAutomation/ne...Dockerfile and call "docker build -t thisismyfirstcontainer:1.0 ." in the folder you put the Dockerfile to ... and you will see it will build the HDMI image on your original RPi3. if you call "docker images" after the build you will recognize the container image named as "thisismyfirstcontainer:1.0".

The manual way I have described here 4 years ago https://www.netiot.com/netpi/industrial-...pberry-pi/

I also recommend to make a simple test to get familiar with Docker first of all. Deploy a hello-world container first as described here https://iotbytes.wordpress.com/setting-u...container/

You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

You also asked me how to use NPIX-4DI4DO module in a container. All 4 DOs and 4 DIs are connected to standard GPIOs pins of the Raspberry CPU. So you need to know just how to access GPIO in general on netPI/Raspberry Pi.

Here is what you need to know. Since netPI is 100% identical to Raspberr Pi 3B all the chapters found on the Internet like https://raspberrypi-aa.github.io/session2/bash.html also apply for netPI. The example shows how to use GPIOs from command shell and bash scripts. There are also python libraries that can access GPIO signals. Also for Javascript and also for C or C++. So you need to know which language you want to use to access GPIOs.

As next you need to know that accessing hardware specific things on a machine within a container needs special container start parameter so that it can access the hardware. Accessing GPIOs in a container running on netPI needs "privileged" mode enabled and also device "/dev/gpio" mapped.

You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

Dear Armin,

Could I ask you one more question on this topic?

If I have an application developed on Raspbian OS with commercial (standard) Raspberry Pi, is it possible to execute the application in a container of hilschernetpi/netpi-raspbian on netPI?
If so, I think Docker doesn't have to be installed on Raspberry Pi to create a container image.

Thank you very much for your feedback in advance.
Best regards,
If you have an application natively installed under Raspbian OS today then it is not possible any more to put this application in an container afterwards.

So you have to start with Docker and install it on your standard Raspberry Pi under Raspbian OS first. Then you deploy a basic container like "hilschernetpi/netpi-raspbian" on top. So it is a kind of double Raspbian OS and sounds odd in the first moment ... but with this constellation the containerized Raspbian OS is gettting portable and all the installations your made "inside" , while the native host Raspbian OS is not portable.

So I explain you the manual way WITHOUT using Dockerfile method. This is how I collected my experience with Docker by the way 4 years ago.

So install Docker on your Raspberry Pi first. Call

sudo docker run -it --privileged --network=host --name=mycontainer --entrypoint=/bin/bash hilschernetpi/netpi-raspbian

  • This command installs the hilschernetpi/netpi-raspbian Raspbian OS container (on top of your Raspberry Pi Raspbian OS).
  • This commands also "runs" the container and starts it
  • This commands names the container "mycontainer"
  • This command also calls the Linux bash terminal /bin/bash command inside this container
  • This commaned immediately "runs/jumps" into the container context and leaves the host Raspbian OS context
  • This command changes your current Raspbian OS terminal prompt to the one in the container
    ... now you are in the container Raspbian OS and not on your native host Raspbian OS any more
Continue to call ALL Linux commands as usual and make your installations as usual ... but all installations are now stored in the context of the containerized Raspbian OS. After your are finsihed with all your installations then call


And then you "leave" the container context and your are back to your native host Raspbian OS.

Call the command for simple confirmation

docker ps -a

and you will see that there is container on your system named "mycontainer"

CONTAINER ID  IMAGE                         COMMAND      CREATED         STATUS                      PORTS   NAMES
7a963583225a  hilschernetpi/netpi-raspbian "/bin/bash"  10 seconds ago  Exited (127) 3 seconds ago           mycontainer

What you now can do is creating an image from your edited Raspbian OS container using the command

docker commit mycontainer myrepository/mycontainer:V1.0.0

This command now saves all the contents of your container inclusive all new data to a portable image ... and this image can run on any other machine like netPI.  Just look if the image has been created using the command

docker images

You will get an output like this

REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE
myrepository/mycontainer             V1.0.0              910c7c62ab7d        3 seconds ago       801MB

Finally you can push this image to Docker Hub for example to make it public to everyone ... and then everone can load it on his local machine ... The image must start with the repository name where you want to push the image to. In my example "myrepository" is just a sample name and needs to be replaced by you with a valid name of your Docker hub repository. After that use the command

docker push myrepository/mycontainer:V1.0.0

and the images is immediately uploaded to the Docker hub internet and everyone can grab it.

Supposing your are not satisfied with the current status of your container and you want to add more applications to it then you have to "jump" into the container again. Befor that you have to start it. Call
docker start mycontainer
docker exec -it mycontainer /bin/bash

Then you are again in the container and you can call additional Linux commands in the container. Finally use "exit" to leave again ... create and image V1.0.1 for example, and push it to your registry.

This is all the manual way and time consuming.

You never fail until you stop trying.“, Albert Einstein (1879 - 1955)


Possibly Related Threads…
Thread Author Replies Views Last Post
  Access to RTC from my own container application tad 1 3,789 March-19th-2021, 02:58 PM
Last Post: Armin@netPI
  netpi raspberry Hochschulstudent 1 2,540 August-12th-2020, 01:50 PM
Last Post: Armin@netPI
  CODESYS - Control for Raspberry Florian 1 4,043 March-18th-2019, 06:16 PM
Last Post: Armin@netPI
  Setup trusted Docker registry on a Raspberry Pi to host netPI containers Armin@netPI 12 13,535 January-31st-2019, 06:47 PM
Last Post: Armin@netPI

Forum Jump:

Users browsing this thread: 1 Guest(s)