Running and Building ARM Docker Containers on x86

This section explains how to build an Docker image that will be running on a different platform than the once its built on. For example, if the application is supposed to run on a NVIDIA Jetson device, then it should be built for aarch64 architectures. However this is not possible on a Ubuntu Desktop device which runs on a x86_64 architecture. Here is when the emulation steps in. In this section, we’ll be using QEMU.

Note: For detailed documentation on emulation for Docker with QEMU, please refer to this GitHub.

Setup the Emulation

In the following we provide an example of building a Docker image for aarch64 from a x86_64 host.

First, let’s see what is happening before setuping the emulation when trying to execute a program compiled for a different architecture :

$uname -m # Displaying the host arch

$docker run --rm -t arm64v8/ubuntu uname -m # Running a executable made for aarch64 on x86_64
standard_init_linux.go:211: exec user process caused "exec format error"

As expected the instructions are not recognized since the packages are not installed yet. To setup the emulation use the following command lines:

$sudo apt-get install qemu binfmt-support qemu-user-static # Set up the qemu packages
$docker run --rm --privileged multiarch/qemu-user-static --reset -p yes # This step will execute the registering scripts
$docker run --rm -t arm64v8/ubuntu uname -m # Let's test the emulation again

The installation was successful, the emulation is working. At this point we can now run aarch64 programs on the host x86_64 PC. Unfortunately it is not possible yet to emulate CUDA accelerated program with QEMU. However, this feature can be used to easily build and compile aarch64 programs on the host x86_64 PC (see next section for additional details).

Build Docker Images with Emulation

Once the setup completed, the images can be built for aarch64 by using the required base image in the docker file. For example to build a Docker image for Tegra the following image can be used:

FROM nvidia/l4t-base:r32.2.1

We already provide a base image for the ZED SDK 2.8 on Jetson JetPack 4.2.1. You can use it in your Dockerfile just by adding this line:

FROM stereolabs/zed:2.8-devel-l4t-r32.2.1

To build your image just run the following command:

$docker build -t {custom_image}:{custom_tag} .

Unfortunately it is not possible to run any aarch64 binary that calls into the NVIDIA driver on the x86_64 host. To run the image on the target machine, we recommend pushing the build image to a registry and pull it on the target machine (see section ZED SDK with Docker).