Skip to main content
Version: Torizon OS 6.x.y

How to Autorun an Application With Torizon OS


This article presents information on how to autorun applications on Torizon OS. It explains you how to do it on evaluation and development and on production.

How Applications Start Automatically on Torizon OS?​

Docker, the main engine behind the management of Containers within Torizon OS, is already configured to start at boot via a systemd service. Along with that, there is another systemd service in Torizon OS named docker-compose, which will initialize the containers described by a docker-compose.yml file present in the /var/sota/storage/docker-compose/ directory of your Torizon OS system.

Evaluation and Development​

By default the /var/sota/storage/docker-compose/docker-compose.yml file is present just in the Torizon OS with Evaluation Containers images. These images feature several containers focused on development, like Weston and Portainer, already set to start at boot together with Docker. They can be installed with Toradex Easy Installer.

For development, you can manually create a docker-compose.yml file at /var/sota/storage/docker-compose/ to start the containers at boot. Before moving the docker-compose.yml file, you will need to create that folder, which can be done with sudo mkdir -p /var/sota/storage/docker-compose.

Also, you can create your own Systemd service and start your container through the docker run command, but using the docker-compose.yml method as mentioned above is the preferred way of starting a Container on Torizon OS.

Controlling your Containers Behavior​

Also you can make some adjustments in order to control the behavior of your containers.

That can be done with the restart flag, which can be set through the command line, by docker run or docker update, or by setting the parameter restart at docker-compose.yml for the given container image.

For both command line and docker-compose.yml, the restart parameter flag can assume one of the following values:

  • no: Do not automatically restart the container. (the default)
  • on-failure: Restart the container if it exits due to an error, which manifests as a non-zero exit code.
  • always: Always restart the container if it stops. If it is manually stopped, it is restarted only when Docker daemon restarts or the container itself is manually restarted. (See - the second bullet listed in restart policy details)
  • unless-stopped: Similar to always, except that when the container is stopped (manually or otherwise), it is not restarted even after Docker daemon restarts.

As mentioned previously, the preferred way of starting containers with Torizon OS is through a docker-compose.yml at /var/sota/storage/docker-compose/.

The restart flag parameter is a complement to make it possible to automatically restart given container images, which is done by Docker itself.

In addition to Docker Compose and Docker start and restart, you should also learn more about the Docker container health monitor. It allows you to define custom conditions to restart a container in case it doesn't behave as expected.

Production: Pre-Provisioning Docker Containers onto a Torizon OS Image​

Once you have your docker-compose.yml structured and validated, you can pre-provision a customized Torizon OS image with that, so you can use it for flashing several units, which is very useful for production.

You can find more details about this process in our article Pre-provisioning Docker Containers onto a Torizon OS Image. With the resulting image at the end of this process, the containers defined in your docker-compose.yml will be set to be started automatically.

The process of pre-provisioning a Torizon OS image with custom containers makes use of our TorizonCore Builder Tool.

Send Feedback!