Skip to main content
Version: 6

Deploy Applications to a Container Using a Pre-built Image - The Easy Way

Overview

Toradex provides minimal container images that extend the slim release of Debian with useful features for Torizon OS, limiting dependencies and packages to only the required ones.

Visit the Debian Containers for Torizon page to find more information about available images and how to use them.

In this section you will learn:

  • A simple way to pull a Toradex container image from the server.
  • A simple way to start and use a container based on the pulled image.
  • How to install a simple Debian package on the container and test it.
  • The limitations of this method and why you need to write a Dockerfile to build your own image based on existing Toradex images.
Typographic Conventions

Throughout the Toradex documentation, the following typographic conventions are used:

$ (dollar sign) Command in the host computer (e.g. your PC)

$ Command in your PC

$$ (double dollar sign) Command in a container in the host computer (e.g. your PC)

$$ Command inside a container in your PC

# (hashtag) Command in the target device/board (e.g. Linux terminal)

# Command in the target board, e.g. Colibri iMX6

## (double hashtag) Command inside a container in the target device (Torizon)

## Command inside a container in Torizon

> (greater-than sign) Command in the bootloader (e.g. U-Boot console)

> Command in the Bootloader

No symbol: Command output

$ Command waiting for output
Output

Prerequisites

Step 1

On the module's terminal, run the following command to pull Toradex's Debian image

# docker pull torizon/debian:$CT_TAG_DEBIAN

The command above downloads and stores a container image in its latest version to be used on the board. torizon/debian is a minimal Debian-based image designed to be used on Toradex's Computer on Modules (COMs). The $CT_TAG_DEBIAN is a Torizon-specific environment variable that makes it easier to run containers matching the OS release version.

Step 2

Instantiate and run a new container based on the pulled image:

# docker run --rm -it -v /var/run/dbus:/var/run/dbus -v /dev:/dev torizon/debian:$CT_TAG_DEBIAN bash

The flags on this command provide the container with the necessary permissions to access hardware features from the host. For more information about what these flags do, see the FAQ session at the end of this article.

Step 3

Now the container is running interactively and its terminal is shown. Update the list of available packages:

## apt-get update

Step 4

Use the apt-get install command inside the container to install the nano text editor:

## apt-get install nano

Step 5

Check if the package you have installed is available:

## nano

You are now inside the nano text editor. Press Ctrl + x to exit it.

Step 6

You can exit the container by either typing exit on the command-line or by pressing Ctrl + d:

## exit

Takeaway

You are now ready to start working with a container. You may want to install and run applications inside the container you just created. However, note that any applications installed and data modifications made after the container start will be lost when the container exits (i.e. stops executing). For this reason, the method shown in this article may be useful for debugging/testing, but it is not practical for development purposes.

In the next sections of this tutorial, you will learn how to install Docker on your development PC, discover appropriate techniques for developing applications for Torizon OS, and put them inside container images.

FAQ

What do the `docker run` flags do?
  • -d makes the container run in detached mode, i.e. in the background.
  • -it makes it interactive.
  • --rm removes the container after it is finished
  • -v /var/run/dbus:/var/run/dbus -v /dev:/dev links the board's files that control the display with the container's.
Are all packages from Debian available on the board?

Debian feeds are used, therefore all packages available for the module's architecture (e.g. ARMv7 a.k.a ARM, or ARMv8 a.k.a ARM64 depending on your module) are available on the board. Packages available only for x86 will be missing.

Can I run 32-bit containers on 64-bit platforms?

Preliminary tests show that it is possible, though you are encouraged to use the 64-bit version whenever possible.

What is the difference between a Docker image and container?

An image is a read-only, stateless template, whereas a container is a running instance of it. Multiple containers can be run from the same image.

For comprehensive information, refer to the Docker documentation. For instance, in the Docker overview, there is a section that defines what are images and containers.



Send Feedback!