1. Introduction

With the i-PRO Camera SDK that supports Container AdamApp, you can run containers with various configurations in the i-PRO camera by describing the app configuration in a Docker compose configuration file. This allows you to develop camera application as docker application, and if you have already developed a Docker container running on PC or another device, you can easily port it to camera. This document explains how to create a Container AdamApp with multiple containers using the docker_multi_images sample app included in the SDK as an example.

2. Overview

2.1 Design docker container architecture

Please refer here for information on which to choose between the existing AdamApp, Container AdamApp and Cotainer AdamApp for Azure IoT Edge.

The container configuration depends on Docker compose configuration file (docker-compose.yaml).

Multiple containers also work by specifying multiple service names in the file.

Following diagram shows the difference between the conventional AdamApp(not the docker) and the example of Container AdamApp.

The above is the example of multiple containers within one camera application (one binary).

There are some options and the following are guidelines for selecting the architecture.

No.

Use Cases

Configure the app

Conceptual diagram

1

Port existing docker application for AI processing on PC or another device to i-PRO camera.

One app with one container.

Process to get video image and AI processing need to be replaced by ADAM API

2

Convert exiting AdamApp (conventional i-PRO camera app) to Container AdamApp

An existing app is simply containerized, creating one app with one container.

3

Port existing docker application without AI processing on PC or another device to i-PRO camera.

One app with two containers.

Main container for management by firmware and Sub container for existing container application.

In case existing docker application consist of multiple containers including third party OSS, those will be Sub container 1 and Sub container 2.

4

Port two existing docker applications that has no relation each other.

Two apps

5

Multiple containers that both need to use the ADAM API

Two apps

2.2 Configuration for multiple containers

The sample application “docker_multi_images” is the reference, especially for use case No.3 in Chapter 2.1. This sample app consists of two Docker images.

If you want to run an existing container on an i-PRO camera, you can add the docker_multi_images for management from the camera, and the existing container can be run on the camera with minimal changes.

2.3 Porting Considerations

When running an existing container on an i-PRO camera, you need to consider the following three points:

2.3.1 RAM / ROM / CPU resources

Please see here for resources for CV52 cameras that support docker capabiility.

Please make sure the app you are porting can work within these limits.
RAM/CPU limits are enforced by cgroups. If RAM usage exceeds the limit, the app will be killed by the OOM Killer.

2.3.2 About our security policy

Followings are important points when porting. For more information on Container AdamApp's security policy, please see here.

2.3.3 Restrictions on using ADAM API

If Container AdamApp contains multiple containers, the ADAM API can only be used from the main container, not from sub containers.

It is better that main image has feature related to camera functions and sub images have features not related to camera functions. Chapter 3.4 shows how to share the data between main and sub images.

3. Development Procedure

3.1 Create a project

Preparing the project directory

Copy iPRO_CAMERA_SDK/src/adamapp/docker_multi_images included in the SDK sample app and rename it to any name. It is recommended to use lowercase for all directory names to make it easier to understand if the directory name matches the image name of the main image.

Convert the string "docker_multi_images" contained in container/docker-compose.yaml to the name of the main image in one go.

There is no need to change the main image binary (multiImages). If you want to change it, you will also need to edit Configuration.txt and Makefile.

App information description

Open configuration.txt and edit the following items.

3.2 Preparing the sub-image (the image to be ported)

If you want to port an existing container image, create it as a subimage.

The SDK build script does not build sub-images, so developers must prepare the images themselves in advance.

Build a sub-image using a separate Dockerfile or Docker Compose. Specify arm64 as the architecture (platform) when building.

The following explains how to prepare the nginx image included in docker_multi_images as an example.

3.3 Editing docker-compose.yaml

Write information about the sub-image in docker-compose.yaml.
For information on how to write docker-compose.yaml, please see here etc.

The docker-compose.yaml you edit here will be executed in the camera when the app starts. You cannot use the build command in the file.

3.4 Implementing your own functionality

3.4.1 Communication and data sharing between containers

There are the following methods to exchange data between the main image and sub-image.

The IP address of the camera in the virtual environment can be found from within the container by referencing /etc/hosts from within the container and setting the least significant byte of the last entry to 1.

When accessing via WebAPI, you must specify the camera's user name and password.

3.4.2 Example implementation of sample app

The sample application “docker_multi_images” uses the DNS function of the inter-container network to implement sample code that sends an HTTP request from the main container to a sub-container by container name.
The response_by_html function in ${SDK_DIR}/adamapp/docker_multi_images/main.cpp calls the system function that makes a request with curl as follows. Here, “web” is the service name written in docker-compose.yaml.

	char cmd[256];

	snprintf( cmd, 256, "curl http://web/index.html > /tmp/local/index.html");
	if( system(cmd) != 0 ) {
		ADAM_DEBUG_PRINT(ADAM_LV_ERR, "system error (%s)\n", cmd);
	}

By pressing the "Go to Settings Screen" button for the "Docker Multi-Image" app displayed on the "Software Management Screen" of the camera browser, this code will be called and the contents of index.html of the web container will be displayed directly in the browser.

3.5 Building the app

Please refer to the following for information on building a development environment.

Construct a development environment(Container AdamApp) - Technology Partner FAQ (En) - Confluence (atlassian.net)

Please see below for information on how to develop and build apps.

How to develop(Container AdamApp) - Technology Partner FAQ (En) - Confluence (atlassian.net)