In this tutorial, I will demonstrate how to use Docker to maintain up to date applications at the edge. This application runs on the Advantech routers in the field.
As processing at the edge becomes more and more reality. Providing tools to manage those applications by software development teams without a change in their workflow allows quick adoption and reduction in costs.
If you prefer video format we have made video tutorial as well.
Assumptions for this tutorial we will:
- Router in the field has an assigned dockerize application.
- Router has connectivity to the Docker repository.
- Router has Docker App installed.
- Application is running on the router in the Docker environment.
For the purpose of this tutorial I will dockerize a simple python application, which displays a text on the web page. Such as the screenshot below. Where a web server is serving a web page on port 8000.
We need to install Docker Router App on the ICR-3232.
Then we need to load our Python application Docker Image. I am using the official Docker Hub repository. Other repositories are supported as well, please refer to the documentation.
My test application is `my-python-app-test` so let’s search for it.
Now we need to pull the image `tomasbdureco/my-python-app-test` to the router local storage. Then it will appear in the Images. From there we need to run the application. Thus go into Run action. There we only map the ports from the host environment to the Container environment. As our application should run constantly I choose Restart Policy to be Unless Stopped. This will allow for automatic start, when the router is rebooted or our application crashes for an unexpected reason.
When we click on the Run button our application will start in the background and is ready for action. Navigation to the IP_OF_ROUTER:8000 will show our web page.
At this moment we do have a running Docker application at the edge. This is excellent until the parameters for our application changes and we need to make modifications. In my case I have forgotten an important text to add, which is our company name Dureco. Thus a new version needs to be make and we will move from version 1.0.4 to version 1.0.5.
Let’s make the modifications and publish it to the Docker Hub repository.
I am building the application image for 2 platforms (arm v7 and arm64) and the Docker build command in my case looks like this:
docker buildx build --platform linux/arm/v7,linux/arm64/v8 -t tomasbdureco/my-python-app-test:v1.0.5 --push .
As I need to tag this build with `latest` tag as well I will run the build command again with `latest` tak instead of the version number. I do acknowledge that there is another way of achieving the same ;)
docker buildx build --platform linux/arm/v7,linux/arm64/v8 -t tomasbdureco/my-python-app-test:latest --push .
At that moment the Docker hub repository looks like this:
Ok, we have made our new version of the application and published it into Docker repository. Now we need to update the Docker Image on all the routers, where that application does run.
There are several options on how to achieve it. From a manual process, where we login remotely into all the relevant routers and update it manually, having some scripting done, which will do the same or let router’s themselves update the Docker image and apply it. This is what I choose to do.
So how to actually have routers to do all the work for you? For this proof of concept, I will use a linux script. I will add the creation of this script into a Start-Up Script section of the router. This is important as it means it will become a part of the configuration of the router. When you do a configuration back-up. Secondly we do not need to worry about implementing this functionality and somebody else changing it or removing due to firmware update or other changes being done without knowledge of this functionality running in background.
My script looks like the screenshot below. Be aware this is a POC for production ready solution, please contact us.
What is actually happening here is. The unit will try to get a new version of the application periodically and when it becomes available it will download it and start the new version.
We can double check all is running by visiting the application web page.
In summary, we can let the software developer team to focus on application development and provide functionality, where units at the edge will become part of the continuous integration process. Ensuring the correct version runs on all units in a timely manner without costly and tedious additional manual intervention. This approach has the added benefit of cyber security by limiting potentially less qualified personnel from accessing the units and modifying its configuration.
If you have any questions, would like to investigate how to integrate similar application deployment in your workflow or company, please do not hesitate to contact us.