Introduction
In the previous post, we learned how to start programming our Openmote B board by flashing the onboard LED on our board.
Although in the previous post we learned how to do it using the 'make' tool, in this post we will use Docker, and Docker-compose, to work with containers, although obtaining the same result: blinking the onboard LED of our Openmote B board.
Latest Posts
OpenMote B is an ultra low-power board to develop IoT applications in the industrial space.
It is the reference for the IETF 6TiSCG Working Group and it is supported by the most relevant Open Source 6TiSCG implementation including the Contiki NG and OpenWSN projects.
Docker
But, what is a container? A container is a sandboxed process on your machine that is isolated from all other processes on the host machine. That isolation leverages kernel namespaces and cgroups, features that have been in Linux for a long time. Docker has worked to make these capabilities approachable and easy to use. To summarize, a container:
is a runnable instance of an image. You can create, start, stop, move, or delete a container using the DockerAPI or CLI.
can be run on local machines, virtual machines or deployed to the cloud.
is portable (can be run on any OS)
Containers are isolated from each other and run their own software, binaries, and configurations.
Docker-compose
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
Compose works in all environments: production, staging, development, testing, as well as CI workflows.
Using Compose is basically a three-step process:
Define your app’s environment with a Dockerfile so it can be reproduced anywhere.
Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
Run docker compose up and the Docker compose command starts and runs your entire app. Docker-compose run runs a one-time command against a service. For example, the following command starts the web service and runs bash as its command.
Blinking an on-board LED
Once we know the basics of openmote and docker-compose, we are now ready to run our command.
1. First of all, we are going to Install Docker-compose on our system >>>
2. Then, plug the openmote board into the USB of our computer. (Batteries and antennas are not needed)
3. Go to Our repository >>>, and click on the latest openmote-fw.tar.bz2 to download it.
4. Once downloaded, extract files.
tar -xvf openmote-fw.tar.bz2
5. Go to the directory.
cd openmote-fw/
6. Now, if you cat the docker-compose.yaml file:
cat docker-compose.yaml
The output should be the output below. Let's analyze it:
g. Devices: This is a list of device mappings. Uses the same format as the --device docker client create option.
7. So, once we know what we are going to execute, this is what we are going to do:
Let's run the project called template, with the docker-compose service called openmote. Finally, we are going to remove the container after run with the option --rm.
docker-compose run --rm openmote template
Using Docker for Blinking an OpenMote B on-board LED