Container Preloading¶
This section guides you to configure your platform
images to preload Docker Compose Apps.
By default, the platform
build creates an image to be flashed to a device that
doesn’t include Docker Compose Apps. After installing the image and registering
the device, aktualizr-lite
downloads and runs the configured apps.
There are cases where having applications preloaded on the image can be helpful, such as:
- Executing a Docker Compose App right after the first boot, even without internet or registering the device.
- Reducing network data usage during the Docker Image download.
Note
Preloading container images will increase the size of the system image considerably, especially if the containers have not been optimally constructed.
Refer to the official Docker documentation for best practices on writing Dockerfiles: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
Prerequisites¶
In this guide, it is assumed you already have a container
build with the shellhttpd
enabled:

Fig. 62 FoundriesFactory Containers Targets¶
Click on the latest container
build to see more details.
This tutorial uses shellhttpd
as a reference. Check the Apps available in
your latest Containers build:

Fig. 63 Containers Target Apps¶
Configure the CI¶
Cloning CI Scripts Repository
Clone your ci-scripts
repo and enter its directory:
Edit the factory-config.yml
file and add the configuration below:
factory-config.yml:
enabled
- Whether to produce an archive containing docker images as part of a container build trigger.shortlist
- Defines the list of apps to preload. All Target’s apps are preloaded if it is not specified or its value is empty.app_type
- Defines a type of Apps to preload. If an option is not defined or set to an empty value, theapp_type
preload will depend on the LmP version. If the LmP version is equal to or higher than v85, then restorable type is preloaded, otherwise compose type. See Restorable Apps for more details on Restorable Apps.oe_builtin
- Defines a way to accomplish preloading Apps. If the option is not defined or set to false (by default), then Apps are preloaded by the assemble run of a LmP CI build. Otherwise, Apps are preloaded during an OE build CI run. In this case, rootfs as well as a system image produced by the run includes preloaded Apps. Only Restorable type of Apps (default) are supported by the OE builtin preloader. This option does not work with some of the advanced tagging cases, e.g. in the case of multiple container builds using the same platform (see Advanced Tagging for more details).
Add the factory-config.yml
file, commit and push:
Getting a New Image with Preloaded Containers¶
After these steps, when a platform
or containers
build finishes, it will
generate a .wic.gz
file in Runs, assembly-system-image
, tag
folder, with the preloaded Docker Image.
Find your containers
folder and trigger a new build.
The latest Target named containers-devel
should be the CI job you just created.

Fig. 64 FoundriesFactory New Target¶
When FoundriesFactory CI finishes all jobs, click in the Target, find Runs and download the image from assemble-system-image
:

Fig. 65 FoundriesFactory New Containers Image¶
Flash the image and boot the device, next log in via SSH.
Note
Some devices require additional artifacts to be flashed.
In this case, download the files from the latest platform
build and only use the image
from assembly-system-image
.
For more information about how to flash your device, read Supported Boards.
Testing preloaded Image¶
On your device, switch to root and list the files in the folder
/var/sota/compose-apps/<app>
.
Example Output:
You can also use Docker to list all images available on the device:
Example Output:
For test purposes, it is possible to run the Docker Compose App using the command:
Example Output:
Verify the applications running on the device with the docker ps
command:
Example Output:
Run wget
to test the container:
Example Output:
Testing Preloaded Restorable Apps¶
On your device, switch to root and list the files in the folder
/var/sota/reset-apps
.
Preloaded Restorable Apps should be listed in the output, provided that the preloading was successful.
Example Output:
Another option to verify whether Restorable Apps are preloaded is to use aklite-apps utility.
Example Output:
A user can try to start preloaded Restorable Apps manually by using aklite-apps utility.
Starting Compose Apps Automatically¶
To start the preloaded application automatically (after the boot and before the device registration when aktualizr-lite starts) you have to enable a systemd service responsible for it.
meta-lmp already has a recipe that launches preloaded apps after the device boots.
Clone your meta-subscriber-overrides.git
repo and enter its directory:
Edit the recipes-samples/images/lmp-factory-image.bb
file and add the recipe to the CORE_IMAGE_BASE_INSTALL
list:
recipes-samples/images/lmp-factory-image.bb:
diff --git a/recipes-samples/images/lmp-factory-image.bb b/recipes-samples/images/lmp-factory-image.bb
--- a/recipes-samples/images/lmp-factory-image.bb
+++ b/recipes-samples/images/lmp-factory-image.bb
@@ -30,6 +30,7 @@ CORE_IMAGE_BASE_INSTALL += " \
networkmanager-nmcli \
git \
vim \
+ compose-apps-early-start \
packagegroup-core-full-cmdline-extended \
${@bb.utils.contains('LMP_DISABLE_GPLV3', '1', '', '${CORE_IMAGE_BASE_INSTALL_GPLV3}', d)} \
"
Add the recipes-samples/images/lmp-factory-image.bb
file, commit and push:
The latest Target named platform-devel
should be the CI job you just created.

Fig. 66 FoundriesFactory New Platform Target¶
When FoundriesFactory CI finishes all jobs, click in the Target, find Runs and download the image:

Fig. 67 FoundriesFactory Platform Image¶
Flash the image and boot the device, next log via SSH.
Testing Auto Start¶
Using a second terminal, test your application using curl
from any external
device connected to the same network (e.g. your host machine: the same computer
you use to access your device with ssh).
Example Output:
On your device, use the following command to list the compose-apps-early-start
service:
Example Output:
Verify the compose-apps-early-start
application status:
Example Output:
compose-apps-early-start.service - Ensure apps are configured and running as early>
Loaded: loaded (/usr/lib/systemd/system/compose-apps-early-start.service; enabl>
Active: active (exited) since Wed 2021-03-24 10:25:43 UTC; 5 months 17 days ago
Process: 750 ExecStart=/usr/bin/compose-apps-early-start (code=exited, status=0/>
Main PID: 750 (code=exited, status=0/SUCCESS)
For more information, read Creating Preloaded Images.