Skip to content

Docker Containers on AIR-T

Docker is a powerful platform for developing, shipping, and running applications in containers. One of the key benefits of using Docker is its ability to enhance application portability. Containers encapsulate an application and its dependencies, ensuring consistency across different environments, from development to production. This tutorial will demonstrate how to set up and run a docker container on your AIR-T that has properly exposed the radio drivers to the container.

Note: This tutorial assumes you are running Airstack version 1.0+. If you are running an older version of airstack you will need to follow the legacy steps at the bottom of this tutorial.

Docker Setup

  1. Create a New Working Directory - Make a new directory called airstack-docker and move to it:

    mkdir ~/airstack-docker
    cd ~/airstack-docker

  2. Download the AirStack Drivers - On your AIR-T, you will need to download the driver Debian installation files for your AirStack version. As of AirStack 1.0, a FOR_DOCKER tarball has been provided for your convenience on the Deepwave Developer Portal. Create a sub-directory in airstack-docker called debs and copy all the downloaded .deb files into this directory.

  3. Create the AirStack Dockerfile - Save it with the name Dockerfile inside the airstack-docker directory . Below is an example file to use Python 3.8 on AirStack 1.0.0, but feel free to add your own package requirements.

    FROM --platform=linux/arm64 ${BASE_IMAGE}
    # Don't allow apt-get to prompt user when building a container
    ARG DEBIAN_FRONTEND=noninteractive
    # Basic setup to start installing packages:
    RUN apt-get update && apt-get install -y --no-install-recommends \
        ca-certificates gnupg2 curl git-core \
        && rm -rf /var/lib/apt/lists/* && apt-get clean
    # Required for Airstack Install
    RUN apt-get update && apt-get install -y --no-install-recommends \
        python3-all-dev \
        picosat \
        python3-pexpect \
        python3-responses \
        xonsh \
    # Install Python 3.8 [Optional]
    RUN apt-get update && apt-get install -y --no-install-recommends \
        python3.8 \
    # Required environment variables for CUDA
    ENV CUDA_HOME="/usr/local/cuda"
    ENV PATH="/usr/local/cuda/bin:${PATH}"
    ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}"
    # Install Airstack Files
    WORKDIR /airstack-docker
    COPY debs/* airstack-packages/
    RUN dpkg -i airstack-packages/*.deb
    WORKDIR /home/root
    RUN rm -r /airstack-docker
  4. Build the Docker Container using the typical commands:

    docker build -t air_docker .
    where the -t air_docker is the tag associated with the new container.

  5. Run the Container

    docker run -it air_docker:latest

Legacy Setup

The following steps are only required if you are running a version of Airstack that is older than 1.0. To check your current Airstack version run the SoapySDRUtil --find command.

Map the XDMA and SPI devices into containers

The process below will do this to any container that is spawned using nvidia-container-runtime. NOTE: This will only need to be done one time on the device, unless it is re-imaged.

  1. Create a file named inside the airstack-docker directory and add the following bash script:

    DEVICES=$(find /dev -name "*xdma*"); 
    for dev in $DEVICES; 
        do echo "dev, $dev" >> $MAPFILE;
    DEVICES2=$(find /dev -name "*spidev*");
    for dev2 in $DEVICES2;
        do echo "dev, $dev2" >> $MAPFILE;
  2. Now execute the script using the following command to add the XDMA and SPI devices to the /etc/nvidia-container-runtime/host-files-for-container.d/l4t.csv list:

    sudo bash
  3. Now restart Docker service for the changes to take effect:

    sudo systemctl restart docker.service

Check Linux for Tegra Version

When setting up your Dockerfile you will need to ensure the base container Linux for Tegra version matches your Airstack version.

  1. Determine what Linux for Tegra (L4T) version is running on your AIR-T by running the following command:

    $ cat /etc/nv_tegra_release
    which will return something similar to the following (AirStack 1.0.0):
    # R32 (release), REVISION: 7.4, GCID: 33514132, BOARD: t186ref, EABI: aarch64, DATE: Fri Jun  9 04:18:38 UTC 2023
    The L4T version is found by combining the release with the REVISION: 32.7.4.

  2. Search the NVIDIA L4T Base Catalog for your version and copy the url. If there is not an exact match in the L4T version, select the one that is closest but does not exceed your version. For example, AirStack 1.0.0 has L4T 32.7.4. Looking at the above link reveals that there is a base image for 32.7.1 and 34.1. 32.7.1 is the closest but not newer than our AirStack version, so we choose 32.7.1 as the base image.

Set Runtime to Nvidia

When running a container you will need to specify the runtime to be nvidia. Optionally, you can set this as a default in the docker config file found at: /etc/docker/daemon.json See an example run command below to set the runtime each time you start the container:

docker run --runtime=nvidia -it air_docker:latest

Last update: February 26, 2024