Deploying Container Images to Torizon OS
Introductionβ
The Torizon platform uses containers to package applications that can, in turn, be deployed to the Torizon OS OS. In other words, when you want to deploy a container to Torizon OS, you are looking at a means to deploy your application or part of it to your Computer on Module.
You can deploy container images in a few ways, and the method depends on the phase of the development cycle:
During development:
- From the Torizon IDE extension: This is the preferred option during development because it will abstract away the deployment process. You need to hit
Run
orF5,
and the extension automatically deploys the application and your containers with remote debugging enabled. - From the Command-line Interface (CLI): You can manually deploy images if you don't want to use the IDE extension or Torizon Cloud. There are a few different CLI methods with their advantages and disadvantages.
During production:
- With the TorizonCore Builder: You can generate a custom Torizon OS image that includes your containers, among other customization. This is meant for flashing the board during production, using Toradex Easy Installer.
- From Torizon Cloud: It is a good and convenient way to deploy application updates to a device or a fleet of devices. You will most likely start using it after flashing the board with Torizon OS.
See a summary of the processes described above in the following diagram:
See container registries in more detail on Container Registries.
Prerequisitesβ
- Basic knowledge of Torizon, as presented in the Quickstart Guide.
- A System on Module with Torizon OS.
During Developmentβ
IDE Extensionβ
The Torizon IDE extension makes your life easier by providing several automated tasks to assist the development of containerized applications for embedded. In the development phase, you can use the extension to debug applications running in SoM directly from your host computer. While preparing for production, you can use the extension to build "release" container images, push them to container registries, and integrate your application with the Torizon Cloud.
Command-line Interface (CLI)β
You have a few options when it comes to deployment from the command-line:
- Online registry push and pull: Use the convenient
docker push
anddocker pull
commands to push and pull images, by default, to Docker Hub. It has the drawback that you always must communicate to the Docker Hub - or another online registry server - which is not ideal for development. - Local registry push and pull: The idea is the same as the previous one, except you keep a local registry and don't need a connection with the online registry. It's faster, and you keep things inside of your LAN. It is a nice approach to development.
- Docker save and load: Use the commands
docker save
anddocker load
to pack/unpack the entire image in a compressed tar file. While you can do development on a LAN, it does deploy the whole image every time, instead of layers. On the other hand, you don't need to set up a local registry. - Pull-through Cache: Use Docker registry as a transparent cache, you will be able to configure Docker to pull all images through this cache, after fetching it for the fist time.
Run and Manage Containers from the Command-lineβ
When the container is available either in a Docker registry or on the board, you can follow the next steps by reading the article Run and Manage Containers with Portainer and the Command-line on Torizon. It describes in-depth how to run a container on the board.
During Productionβ
TorizonCore Builder - Toradex Easy Installerβ
The TorizonCore Builder Tool is a command-line tool run on the host computer. Among several features, one of them is to add containers to a fresh (sometimes called vanilla) Torizon OS image.
Make sure to deploy your image to a Docker registry using either
docker push
, as described in the previous section Online Registry Push and Pull, or from the Docker extension for VS Code. The registry must be accessible from your computer.Write a Docker Compose file for your application, as described in the Using Multiple Containers with Torizon OS or have one generated for you if using the Torizon IDE Extension.
Follow the instructions provided in the dedicated article Pre-provisioning Docker Containers onto a Torizon OS image to create a custom Easy Installer image of Torizon with your pre-provisioned Docker container images.
Finally, use the Toradex Easy Installer Tool to install this custom Easy Installer image of Torizon into the internal flash memory of Toradex modules in an extremely simple way.
To learn more about deploying application containers in Torizon-based devices during production, please read our Production Programming & Provisioning article.
Torizon Cloudβ
The Torizon Cloud server does not store container images. Instead, it uses Docker Compose files containing all the information required to run the board's containers.
Push the container image to a docker registry:
If using the Torizon IDE Extension, there is a command that pushes the container image to a docker registry and adds your application to the Torizon Cloud.
If not using the IDE Extension, first of all, make sure to deploy your image to an online Docker registry using either
docker push
, as described in the previous section Online Registry Push and Pull, or from the Docker extension for VS Code.
Write a Docker Compose file for your application, as described in the Using Multiple Containers with Torizon OS or have one generated for you if using the Torizon IDE Extension.
Deploy the update to the board as described in our Quickstart Guide.
If you want to deploy simultaneously the OS and application with Torizon Cloud, you should use the synchronous update feature of our Torizon Cloud, instead of bundling containers to a Torizon OS image.
You can learn more about container application updates with Torizon in the Torizon Updates Overview article.
Private Registries and Torizon Cloudβ
If you decide to use a private container registry to host your images, make sure to follow the article Using Private Registries With Torizon Cloud.