Search by Tags

Pre-provisioning Docker Containers onto a TorizonCore image

 

Article updated at 16 Sep 2020
Compare with Revision




Subscribe for this article updates

Select the version of your OS from the tabs below. If you don't know the version you are using, run the command cat /etc/os-release or cat /etc/issue on the board.

Torizon 5.0.0

Introduction

This article shows how to preinstall or pre-provision a Docker Containers onto a TorizonCore image with a Docker engine. This process is especially useful when preparing an image to be flashed on several units in production.

In this article, we show how to preinstall a Docker Container onto a TorizonCore image using either a Linux Host PC or a Windows machine.

The process comprises two stages:

  • Bundle the Docker Containers: This step creates a tarball containing all the containers as well as a Docker Compose file, which references those containers using a specific hash.

  • Combine the Docker Containers Bundle with a TorizonCore image: In this step, the script takes a Toradex Easy Installer image of TorizonCore with the Docker engine and combines it with the previously bundled Docker Containers.

The process makes use of Docker in Docker, which requires the script to have access to the host Docker engine.

This article complies to the Typographic Conventions for Torizon Documentation.

Pre-requisites

The pre-requisite to complete these instructions are:

Using TorizonCore builder on Linux

Preparation

Make sure to use an empty working directory and navigate to it. This directory is shared (bind-mounted) with the container this tool runs in, and it stores temporary files and the final image.

$ mkdir ~/myworkdir/
$ cd ~/myworkdir/

Inside the myworkdir directory, create the image and image_output folders.

$ mkdir image image_output

For convenience, create an alias called torizoncore-builder for the container execution:

$ alias torizoncore-builder='docker run --rm -it -v $(pwd):/workdir --net=host \
-v /var/run/docker.sock:/var/run/docker.sock torizon/torizoncore-builder'

Note: The bind mounts of the host Docker need to match the location inside the torizoncore-builder script (/builder). For that reason, you should use this alias (torizoncore-builder) only in this directory which it was created.

Gather the image file and the docker-compose file

Copy your project's docker-compose.yml file to the working directory.

As an example, we will use a simple docker-compose file:

docker-compose.yml
version: '2.4' services: hello-world: image: hello-world

Add the .tar file containing the TorizonCore Image with no-container pre-provisoned for offline instalation to the image directory.

After copying these two files to the working directory, we check its content:

$ tree .
.
├── docker-compose.yml
├── image
│   └── teziimage.tar
└── image_output

Create a container bundle

With the files on the directory, call the bundle command to create a container bundle:

$ torizoncore-builder bundle --host-workdir=$(pwd) --platform=linux/arm/v7 --file docker-compose.yml

Attention: Replace --platform=linux/arm/v7 by --platform=linux/arm/v8 when using a 64-bit SoC (iMX8).

This step downloads the Docker in Docker container image and uses the docker-compose.yml template to download all images referenced in this Docker Compose file. The tool then compresses the complete set of Docker containers on a tar file.

The container bundle tarball will be located at the new directory ./bundle/.

Combine the container images bundle with TorizonCore image

Before running this step, make sure to have a TorizonCore image tarball available in your work directory, as explained earlier.

To combine the container images bundle with TorizonCore image:

$ torizoncore-builder combine --image-directory ./image --output-directory ./image_output

After running this process, a combined TorizonCore image is available in the output directory specified by the --output-directory flag. This image is ready to be installed into the SoM using Toradex Easy Installer

Using TorizonCore builder on Windows 10

Warning: This procedure requires Windows 10 with WSL2 installed

To execute the following instructions, the Windows Subsystem for Linux version 2(WSL2) is necessary. WSL2 is available when updating Windows 10 to the version 2004 (Build 19041) or higher.

Preparation

Open the Windows command prompt (cmd) and make sure to use an empty working directory and navigate to it. This directory is shared (bind-mounted) with the container this tool runs in, and it stores temporary files and the final image.

C:\Users\My User>mkdir myworkdir/
C:\Users\My User>cd myworkdir/
C:\Users\My User\myworkdir>

Inside the myworkdir directory, create the image and image_output folders.

C:\Users\My User\myworkdir>mkdir image
C:\Users\My User\myworkdir>mkdir image_output

Gather the image file and the docker-compose file

Copy your project's docker-compose.yml file to the working directory.

As an example, we will use a simple docker-compose file:

docker-compose.yml
version: '2.4' services: hello-world: image: hello-world

Add the .tar file containing the TorizonCore Image with no-container pre-provisoned for offline instalation to the image directory.

After copying these two files to the working directory, we check the myworkdir directory content:

├── docker-compose.yml
├── image
│   └── teziimage.tar
└── image_output

Create a container bundle

With the files on the directory, call the bundle command to create a container bundle:

C:\Users\My User\myworkdir>docker run --rm -it --net=host ^
-v "C:\Users\My User\myworkdir":/workdir -v /var/run/docker.sock:/var/run/docker.sock ^
torizon/torizoncore-builder bundle --host-workdir="/c/Users/My User/myworkdir" ^
--platform=linux/arm/v7 --file docker-compose.yml

Attention: Replace --platform=linux/arm/v7 by --platform=linux/arm/v8 when using a 64-bit SoC (iMX8).

This step downloads the Docker in Docker container image and uses the docker-compose.yml template to download all images referenced in this Docker Compose file. The tool then compresses the complete set of Docker containers on a tar file.

The container bundle tarball will be located at the new directory ./bundle/.

Combine the container images with TorizonCore

Before running this step, make sure to have a TorizonCore image tarball available in your work directory, as explained earlier.

To combine the container images bundle with TorizonCore image:

C:\Users\My User\myworkdir>docker run --rm -it --net=host ^
-v "C:\Users\My User\myworkdir":/workdir -v /var/run/docker.sock:/var/run/docker.sock ^
torizon/torizoncore-builder combine --image-directory image ^
--output-directory image_output

After running this process, a combined TorizonCore image is available in the output directory specified by the --output-directory flag. This image is ready to be installed into the SoM using Toradex Easy Installer

Torizon 4.0.0

Introduction

This article shows how to preinstall or pre-provision a Docker Containers onto a TorizonCore image with a Docker engine. This process is especially useful when preparing an image to be flashed on several units in production.

In this article, we show how to preinstall a Docker Container onto a TorizonCore image using either a Linux Host PC or a Windows machine.

The process comprises two stages:

  • Bundle the Docker Containers: This step creates a tarball containing all the containers as well as a Docker Compose file, which references those containers using a specific hash.

  • Combine the Docker Containers Bundle with a TorizonCore image: In this step, the script takes a Toradex Easy Installer image of TorizonCore with the Docker engine and combines it with the previously bundled Docker Containers.

The process makes use of Docker in Docker, which requires the script to have access to the host Docker engine.

This article complies to the Typographic Conventions for Torizon Documentation.

Pre-requisites

The pre-requisite to complete these instructions are:

Using TorizonCore builder on Linux

Preparation

Make sure to use an empty working directory and navigate to it. This directory is shared (bind-mounted) with the container this tool runs in, and it stores temporary files and the final image.

$ mkdir ~/myworkdir/
$ cd ~/myworkdir/

Inside the myworkdir directory, create the image and image_output folders.

$ mkdir image image_output

For convenience, create an alias called torizoncore-builder for the container execution:

$ alias torizoncore-builder='docker run --rm -it -v $(pwd):/workdir --net=host \
-v /var/run/docker.sock:/var/run/docker.sock torizon/torizoncore-builder'

Note: The bind mounts of the host Docker need to match the location inside the torizoncore-builder script (/builder). For that reason, you should use this alias (torizoncore-builder) only in this directory which it was created.

Gather the image file and the docker-compose file

Copy your project's docker-compose.yml file to the working directory.

As an example, we will use a simple docker-compose file:

docker-compose.yml
version: '2.4' services: hello-world: image: hello-world

Add the .tar file containing the TorizonCore Image with no-container pre-provisoned for offline instalation to the image directory.

After copying these two files to the working directory, we check its content:

$ tree .
.
├── docker-compose.yml
├── image
│   └── teziimage.tar
└── image_output

Create a container bundle

With the files on the directory, call the bundle command to create a container bundle:

$ torizoncore-builder bundle --host-workdir=$(pwd) --platform=linux/arm/v7 --file docker-compose.yml

Attention: Replace --platform=linux/arm/v7 by --platform=linux/arm/v8 when using a 64-bit SoC (iMX8).

This step downloads the Docker in Docker container image and uses the docker-compose.yml template to download all images referenced in this Docker Compose file. The tool then compresses the complete set of Docker containers on a tar file.

The container bundle tarball will be located at the new directory ./bundle/.

Combine the container images bundle with TorizonCore image

Before running this step, make sure to have a TorizonCore image tarball available in your work directory, as explained earlier.

To combine the container images bundle with TorizonCore image:

$ torizoncore-builder combine --image-directory ./image --output-directory ./image_output

After running this process, a combined TorizonCore image is available in the output directory specified by the --output-directory flag. This image is ready to be installed into the SoM using Toradex Easy Installer

Using TorizonCore builder on Windows 10

Warning: This procedure requires Windows 10 with WSL2 installed

To execute the following instructions, the Windows Subsystem for Linux version 2(WSL2) is necessary. WSL2 is available when updating Windows 10 to the version 2004 (Build 19041) or higher.

Preparation

Open the Windows command prompt (cmd) and make sure to use an empty working directory and navigate to it. This directory is shared (bind-mounted) with the container this tool runs in, and it stores temporary files and the final image.

C:\Users\My User>mkdir myworkdir/
C:\Users\My User>cd myworkdir/
C:\Users\My User\myworkdir>

Inside the myworkdir directory, create the image and image_output folders.

C:\Users\My User\myworkdir>mkdir image
C:\Users\My User\myworkdir>mkdir image_output

Gather the image file and the docker-compose file

Copy your project's docker-compose.yml file to the working directory.

As an example, we will use a simple docker-compose file:

docker-compose.yml
version: '2.4' services: hello-world: image: hello-world

Add the .tar file containing the TorizonCore Image with no-container pre-provisoned for offline instalation to the image directory.

After copying these two files to the working directory, we check the myworkdir directory content:

├── docker-compose.yml
├── image
│   └── teziimage.tar
└── image_output

Create a container bundle

With the files on the directory, call the bundle command to create a container bundle:

C:\Users\My User\myworkdir>docker run --rm -it --net=host ^
-v "C:\Users\My User\myworkdir":/workdir -v /var/run/docker.sock:/var/run/docker.sock ^
torizon/torizoncore-builder bundle --host-workdir="/c/Users/My User/myworkdir" ^
--platform=linux/arm/v7 --file docker-compose.yml

Attention: Replace --platform=linux/arm/v7 by --platform=linux/arm/v8 when using a 64-bit SoC (iMX8).

This step downloads the Docker in Docker container image and uses the docker-compose.yml template to download all images referenced in this Docker Compose file. The tool then compresses the complete set of Docker containers on a tar file.

The container bundle tarball will be located at the new directory ./bundle/.

Combine the container images with TorizonCore

Before running this step, make sure to have a TorizonCore image tarball available in your work directory, as explained earlier.

To combine the container images bundle with TorizonCore image:

C:\Users\My User\myworkdir>docker run --rm -it --net=host ^
-v "C:\Users\My User\myworkdir":/workdir -v /var/run/docker.sock:/var/run/docker.sock ^
torizon/torizoncore-builder combine --image-directory image ^
--output-directory image_output

After running this process, a combined TorizonCore image is available in the output directory specified by the --output-directory flag. This image is ready to be installed into the SoM using Toradex Easy Installer