Building a base QNX Container image
In this section, you build a base container image; a minimal filesystem to use as a common building block for several container application images.
Typically, this base image includes any SDP dependencies for your applications. From the base image, you can create several images depending on the type of applications you're building (e.g., an image for resource manager applications, another for network applications, etc.)
Note:
The creation of this base image is optional,
as these SDP dependencies may also be included directly as part of
the build process when the QNX Container application image is built,
or alternatively, the dependencies can be mounted directly from the host filesystem.
Below is an example script of building a base image:
ARCH= IMAGE_TAG= TARGET_DIR= IMAGE_NAME="qnx-base" IMAGE_VER=$(cat $QNX_TARGET/usr/include/sys/nto_version.h | grep -w _NTO_VERSION | awk '{print $3}') ROOTFS=$(mktemp -d ${TMPDIR:-/var/tmp}/rootfs-qnxbase-XXXXXXXXXX) USR_LIB_DIR=$ROOTFS/usr/lib PROC_BOOT_DIR=$ROOTFS/proc/boot SYSTEM_XBIN_DIR=$ROOTFS/system/bin function __cleanup__() { sudo rm -rf $ROOTFS } print_usage() { echo "Usage:" echo $(basename "$0") "-a <x86_64|aarch64>" } make_base_qnx800_image() { local libs="lib/libc.so.6 lib/libgcc_s.so.1 usr/lib/ldqnx-64.so.2 lib/libregex.so.1 lib/libsecpol.so.1 lib/libfsnotify.so.1 lib/libm.so.3 lib/libjail.so.1 lib/libsocket.so.4 usr/lib/libz.so.2 usr/lib/libexpat.so.2" local system_bins="usr/bin/toybox sbin/pipe sbin/ifconfig sbin/route sbin/ping" local toybox_bins="ls ln sed pwd find env which cp cat clear echo mkdir mv rm rmdir touch tail" mkdir -p $PROC_BOOT_DIR for lib in $libs; do cp $TARGET_DIR/$lib $PROC_BOOT_DIR/ done cp $TARGET_DIR/bin/ksh $PROC_BOOT_DIR/ ln -nrfs $PROC_BOOT_DIR/ksh $PROC_BOOT_DIR/sh mkdir -p $USR_LIB_DIR ln -nrfs $PROC_BOOT_DIR/ldqnx-64.so.2 $USR_LIB_DIR/ldqnx-64.so.2 mkdir -p $SYSTEM_XBIN_DIR for bin in $system_bins; do cp $TARGET_DIR/$bin $SYSTEM_XBIN_DIR/ done for bin in $toybox_bins; do ln -nrfs $SYSTEM_XBIN_DIR/toybox $SYSTEM_XBIN_DIR/$bin done # Set the ownership and permissions of the base filesystem as desired # root:root/755 is the common default for *nix systems, but you may # want to change this sudo chown -R root:root $ROOTFS sudo chmod 755 $ROOTFS } ############################################################ # Entry Point # ############################################################ while :; do case $1 in -a) ARCH=$2 ;; -h) print_usage exit 0 ;; *) break esac shift done if [ -z "$QNX_TARGET" ]; then echo "QNX target env variable not found, did you source the sdk script?" exit 1 fi if [ -z "$ARCH" ]; then echo "Missing arguments!" print_usage exit 1 fi if [[ ! "$ARCH" =~ ^(x86_64|aarch64)$ ]]; then echo "Invalid architecture specified!" print_usage exit 1 fi IMAGE_TAG=$IMAGE_NAME-$ARCH:$IMAGE_VER TARGET_DIR=$QNX_TARGET/$ARCH* if [ "$IMAGE_VER" -eq 800 ]; then make_base_qnx800_image else echo "Unsupported SDK version $IMAGE_VER" fi # Note --platform is used to set the correct architecture in the image. Since "qnx" is not yet a supported # OS in docker, the value "linux" is used for now tar --numeric-owner --xattrs --acls -C $ROOTFS -c . | docker import --platform linux/$ARCH - $IMAGE_TAG docker image ls $IMAGE_TAG
Note:
You must source the QNX SDP environment script before running the script.
After running this script (with the desired architecture, x86_64 or aarch64, as argument),
a local image should now appear in the output of docker images:
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
qnx-base-aarch64 800 5785d8cd2379 About a minute ago 4.22MB
qnx-base-x86_64 800 a99d02be47bc About a minute ago 4.32MB
Page updated:
