Docker is a container technology that allows applications including all necessary libraries and dependencies to run in an isolated environment. This enables applications to be installed and operated independently of the operating system.
Control, edge, or IIoT applications can be clearly separated from one another and run reproducibly on the RevPi. Multiple applications can run in parallel without affecting each other. Updates or rollbacks can be performed quickly by starting a new container.
Docker also simplifies the development and deployment of applications, as the same container environment runs identically on development machines, test systems, and the RevPi. This makes Docker particularly suitable for modular edge and IIoT architectures on the RevPi.
Installing Docker #
To install Docker on the RevPi, you can follow the instructions in the Docker Manual Install Docker Engine on Debian.
Alternatively, you can use the docker.io packages from Debian. They do not require an additional package source and may install more quickly.
Accessing RevPi I/O Modules #
The RevPi I/O modules are provided via the piControl driver. This driver provides a process image of the I/O values, which is accessed via the device file /dev/piControl0. Applications can read inputs or write outputs via this file. In order for a Docker container to access the I/Os, this device must be passed into the container when the container starts.
In addition, it may be necessary to grant access to the config.rsc file, for example, for revpi-modbus or revpimodio2.
Prerequisites #
✓ RevPi DIO is connected to your base module
✓ An external LED indicator is connected to the OUT 1 pin of the RevPi DIO
✓ The RevPi system is configured in PiCtory
Creating a Docker Compose File #
▷ Create a docker-compose.yml file to access /dev/piControl0, for example:
services:
pibridge-tester:
image: debian:bookworm-slim
container_name: revpi_pibridge_test
devices:
- "/dev/piControl0:/dev/piControl0"
volumes:
- "/usr/bin/piTest:/usr/bin/piTest"
# In case you need the PiCtory configuration (e.g., revpi-modbus)
- "/etc/revpi/config.rsc:/etc/revpi/config.rsc"
command: bash -c "piTest -w O_1,1
&& sleep 3
&& piTest -w O_1,0"
▷ Run docker-compose.yml:
sudo docker compose up
❯ The LED lights up for 3 seconds.
❯ The following is returned:
[+] up 1/1
✔ Container revpi_pibridge_test Created 0.2s
Attaching to revpi_pibridge_test
revpi_pibridge_test | Set bit 0 on byte at offset 101. Value 1
revpi_pibridge_test | Set bit 0 on byte at offset 101. Value 0
revpi_pibridge_test exited with code 0