Search by Tags

Modifying TorizonCore Debian Based Container Images


Article updated at 27 Mar 2020
Compare with Revision

Subscribe for this article updates


Toradex provides Docker Debian-based container images. In order to take full advantage of them, this article will show you how to modify them to fit your necessities, here are two ways to modify our container images:

  • Run commands directly in a container (useful only to develop the Dockerfile or for quick prototyping)
  • Write Dockerfile (most commonly used and recommended method)

This article complies to the Typographic Conventions for Torizon Documentation.


To have a better understanding of this article the following prerequisites are proposed:

Build a Container based on TorizonCore's Debian-based Docker Images

Working in the Container

It is common to quickly test changes in a running container before you actually build your own customized container image. This can also be a useful method to debug issues that can occur when building a container image.

Let's start by running the base Debian image.

$ docker run -it torizon/arm32v7-debian-base /bin/bash

This should place you in a terminal prompt within the Debian container.

From here you can execute commands and install any package provided by the Debian distribution. For example perhaps you'd want the nano text editor.

$$ apt-get update && apt-get nano

As you can see by just running commands in the container directly you can quickly validate and test your customized container.

It should be noted that this method should only be used for early development and that to truly create your own container image a Dockerfile should be used.

Writing a Dockerfile

In this section we will actually build a container image in a way that is reproducible and can be versioned controlled. For these reasons this should generally be the go-to method when modifying another container image.

Begin by creating a file named Dockerfile, this acts as the "source" file for a container image. In this case we are going to add the nano text editor like we did in the above section:

FROM torizon/arm32v7-debian-base RUN apt update && apt install nano -y
FROM torizon/arm64v8-debian-base RUN apt update && apt install nano -y

Note: a standard Dockerfile has no extension, therefore make sure your file is not named Dockerfile.txt, especially since file extensions are hidden by default. Consult this lesson's FAQ for details about naming.

After creating the file, you can log in to your Docker account:

$ docker login

Now that you are logged to your credentials and the file was created, it's time to finally build your image:

$ docker build -t <username>/my-dockerfile .

Here we can see how working with Dockerfiles have a similar workflow to standard software development (change -> build -> push). For more information on Dockerfiles please reference the official Docker documentation here.

Deploying to the Board

Once you've built your container image using a Dockerfile, you then have a couple of options when it comes to deployment.

Docker Push and Pull

The first option is to use the traditional docker push/pull method. This requires a dockerhub account or some other container registry to push your container image to. First we push the container image.

$ docker push <username>/my-dockerfile

Now your container image can be accessed on any other device such as your computer on module running TorizonCore.

# docker pull <username>/my-dockerfile

Docker Save and Load

The other option for deployment uses docker load/save. First you'll save your docker image as a portable tar archive file.

$ docker save -o my-dockerfile.tar <username>/my-dockerfile

Then you can copy this tar archive to your target device.

$ scp my-dockerfile.tar torizon@X.X.X.X:/home/torizon/

Finally you can then load the tar archive which will then put the container image on your target device.

# docker load -i my-dockerfile.tar

Docker Multi-stage Build

Downloading the final image takes a lot of time and space, so it's very important to keep it tiny. With multi-stage builds, you can build a docker image in stages with multiple FROM instructions in your Dockerfile. Each FROM instruction starts a new build stage and you can copy only the layers which are necessary from the previous stage. This is very useful to avoid including build dependencies in your final image and it also becomes easier to understand.

For more information, please refer to Docker Multistage documentation.

Next Steps