Build Boot2Qt to run within docker in torizon

Hello everyone,

Currently, we are in the process of developing and producing our own Boot2Qt based image, which you can learn more about here: How to Create Boot to Qt Image | Boot to Qt 6.5.2.

In addition to this, we have implemented our custom meta-layer that introduces various drivers and features. Our application utilizes serial ports and CAN Bus functionality. Given that this application serves as the primary GUI for our device, it also facilitates the adjustment of local settings such as static IP configuration, device shutdown and reboot, timezone settings, and more.

Looking ahead, we anticipate incorporating Docker support to enable the deployment of multiple features like mariadb. Furthermore, we’re interested in integrating an over-the-air (OTA) update capability, potentially using SWUpdate or OSTree.

At this juncture, Torizon appears to align well with our requirements. However, after thorough experimentation and testing, we’ve found that the Qt5 debian container image provided by toradex is not ideal for our situation. This is mainly because it’s locked at Qt version 5.15.2, whereas we’ve recently transitioned to Qt version 6.5.2. As we hold a commercial license for Qt Device Creation, we wish to continue leveraging its benefits, including the Qt 6.5 LTS releases and Qt Device Utilities outlined here: Qt Device Utilities 6.4.0 | Qt Device Utilities 6.4.0.

Consequently, I have a specific inquiry:
Is it feasible to construct a custom Boot2Qt image using Yocto and subsequently run it within a Docker container in the Torizon environment?

I’ve already attempted to follow the instructions provided in this video tutorial: https://www.youtube.com/watch?v=_Y9mUT1Phi8&ab_channel=QtDayItalia. However, it seems that the content of the tutorial might be outdated. Could you provide guidance on an effective approach, potentially involving the use of Dockerfiles and docker-compose?

Hi @Romain.Donze ,

It should be feasible to build a base container image from your Yocto-made Boot2Qt with the usage of docker import, as detailed in the Docker documentation:

In summary, you would need to pass the root filesystem of your Boot2Qt image as an input to docker import.

Just keep in mind that we haven’t tested this specifically, so we’re not sure if there are any other details to actually get the container up and running.

Try doing that and see if it works.

Best regards,
Lucas Akira

Hi @lucas_a.tx ,

So I tried some things. bitbake give me a b2qt-embedded-qt6-image-apalis-imx8.tar.xz so I moved it to my target (Apalis iMX8) and tried to import it with docker import ./b2qt-embedded-qt6-image-apalis-imx8.tar.xz but this is resulting with this error Error response from daemon: xz resolves to executable in current directory (./xz).

So on my host machine I did this:

tar -vxf b2qt-embedded-qt6-image-apalis-imx8.tar.xz -C b2qt-image/
tar -czvf b2qt-image.tar.gz b2qt-image/

Then retried the firt step, and I got this:

docker import ./b2qt-image.tar.gz
sha256:972fe5572e53ecedf82727c370ff19c62ee81321f8b8815855a8b8159641f49f

Which means it worked, the output of docker images gave me this

REPOSITORY TAG IMAGE ID CREATED SIZE
none none a1c5c04f91bd 5 minutes ago 1.94GB
phpmyadmin latest dc580ce98624 11 days ago 572MB
mariadb latest c69dda45a934 12 days ago 386MB
torizon/weston-vivante 3 64c4cfb09780 2 months ago 524MB
portainer/portainer-ce 2.17.1 ada025d39772 6 months ago 267MB
torizon/torizon-provisioner 0.0.11 09af1149c647 20 months ago 10MB

Then by looking at the command used in the video, I tried to run my images like so:

docker run --name=b2qt-image -d -it --privileged --restart=always -p2222:22 -p10000-10100:10000-10100 a1c5c04f91bd /entrypoint.sh

the output is:

50b563e9a022c21b349fbefac3ba51aa1b6a00ee31694200ebce4636430fb04a
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: “/entrypoint.sh”: stat /entrypoint.sh: no such file or directory: unknown.

Which I can understand, because I never created an entrypoint.sh file. wich seems necessary to run this container.

I also tried to add manually this file in my tarball but with the same result
entrypoint.sh (3.0 KB)

So what am I missing here?

It would be nice from Toradex to provide some kind of documentation/tutorial on how to build and run a yocto image with torizon/docker. Since apparently it has already been done by one of your employee.

Edit:
After some tries, I managed to run the image (I had to create the tar.gz file like so: tar -czvf b2qt-image.tar.gz b2qt-image --transform s/b2qt-image/./) But it seems that there is boot loop because docker ps returns this always:

215b47bd0659   7c4f79f30ade             "/entry.sh"              10 minutes ago   Up Less than a second   0.0.0.0:10000-10100->10000-10100/tcp, :::10000-10100->10000-10100/tcp, 0.0.0.0:2222->22/tcp, :::2222->22/tcp   b2qt-image

and a few seconds later:

215b47bd0659   7c4f79f30ade             "/entry.sh"              10 minutes ago   Restarting (1) 22 seconds ago

maybe because of the entry.sh file? I really don’t know what to write in it as I just copied it from a docker-hub boot2qt image for colibri-imx7 from 5 years ago (https://hub.docker.com/r/bshibley/colibri-imx7-yocto-boot2qt/tags)

Hi @Romain.Donze ,

Then retried the firt step, and I got this:

docker import ./b2qt-image.tar.gz
sha256:972fe5572e53ecedf82727c370ff19c62ee81321f8b8815855a8b8159641f49f

Which means it worked, the output of docker images gave me this

Right, you managed to build a container image with docker import. As a quick note, you can optionally specify a name and a tag for your built image when importing e.g.

docker import ./b2qt-image.tar.gz b2qt-image:custom

In the video they put in the image a script called entrypoint.sh to be executed when the container is initialized. You don’t need to have it to run your container image, that’s just how they did it.

For example, if you want a shell prompt inside the container when running it you can specify /bin/bash or bash instead of entrypoint.sh in the docker run command, along with the -it options and without the detached (-d) option.

The boot loop is expected behavior considering the docker run command you executed: the container is initialized, runs entry.sh, then exits after the script execution ends. The --restart=always argument means that the container will be restarted every time it exits, so that’s what causes the loop.

You questions are related to running containers with docker run and its different options. I’d recommend you take a look at the Docker docs for a more in-depth explanation that should answer most of your questions related to containers:

Best regards,
Lucas Akira