BalenaOS as docker on RPI4 error

I’m trying to run balenaOS in a docker container on a RPI4 (Raspbian latest) and then run a python application service. I’m able to run balenaOS in a container but when a service is added I get the same error across several balena example projects
standard_init_linux.go:207: exec user process caused “exec format error”

the balenaOS images specify OS/ARCH linux/amd64 where my docker install is linux/arm.

any help debugging the issue?

balenaOS
resin/resinos:2020.04.0.dev-raspberry-pi

docker (on raspbian)
Client: Docker Engine - Community
Version: 19.03.8
API version: 1.40
Go version: go1.12.17
Git commit: afacb8b
Built: Wed Mar 11 01:35:24 2020
OS/Arch: linux/arm
Experimental: false

balena-engine version (balenaOS host)
version: 18.09.10-dev
api version: 1.39
Go version: go1.10.8
OS/ARCH: linux/arm

Hi

The issue that you are seeing is typically seen when the architecture that you are trying to run an application on, isn’t the one that the application was compiled for. So for example if you tried running an aarch64 application on x86 or something similar. You should pick the right os image for your architecture.

thanks @anujdeshpande,
Although I’m still not sure where the incompatibility is. I am able to run (launch from Docker on Raspbian OS) BalenaOS image even though my OS/ARCH is linux/armv71 while the image is specified as linux/amd64. The container is communicating with BalenaCloud and I can push application builds from BalenaCLI.
BalenaOS image tag: resin/resinos:2020.04.0.dev-raspberry-pi

From there, I’ve tried building an application image (in BalenaCloud) and pushing to my devices using balenaLib base image and python base image from docker hub. In both cases, the image is successfully built but continually restarts with the above error.

the balenaOS in a docker container respiratory looks to only offer builds of OS/ARCH linux/amd64
https://hub.docker.com/r/resin/resinos/tags?page=1

is there a balenaOS image (for docker) that runs on armv71 out there?

Hi,

Is there a reason you want to run balenaOS in a container and then run a container inside that? You could just use one of the balenalib python images and build your service natively. BalenaOS essentially runs Docker on the HostOS, and you can deploy containers on it.

John

@jtonello
running balenaOS in a container is a work around. I have several pieces of external hardware for wireless communication that needs to configured using systemd and kernel. I originally was able to configure in Raspbian but balenaOS makes it a little hard to do, thus running balenaOS in a container allows configuration of the host while still having the benefit of balena supervisor and remote deployment.
BalenaOS does offer wifi hotspot and GSM configuration (https://www.balena.io/docs/reference/OS/network/2.x/#cellular-modem-setup).
For the hotspot, I still need to figure out how to configure static IP address for my known clients (I know the mac address a priori). For the GSM, I still need to test my hardware compatibility with ModemManager and balenaOS.

So again, running balenaOS in a container was a faster known path to configure the host wifi hotspot and GSM.

Hello there, have you seen this repository: https://github.com/balena-os/balenaos-in-container? There are a few scripts in there that might be of interest to you.
That said, we do not recommend using balenaOS in container for production environments as it’ss mostly uncharted territory at this point.

thanks @tmigone
I used that repository to build a balenaOS image running on my RPI4 docker daemon. Prerequisite #4 states the balenaOS image needs to be compatible with host architecture. My confusion above is about where the incompatibility resides. The repository links to resin/resinos docker repository where I found the raspberry-pi tag to use in the docker build script
docker pull resin/resinos:2020.04.0.dev-raspberry-pi
I assumed this image is compatible with raspberry-pi but the image OS/ARCH lists linux/amd64, which the PI is not.

I assumed this image is compatible with raspberry-pi but the image OS/ARCH lists linux/amd64, which the PI is not.

@rcalderon, perhaps the CPU architecture mismatch is not between arm and amd64, but rather between the different RPi architectures:

Or not. But I think I have got evidence that the images linked above are not amd64 images, because I actually got a couple of them running on a Raspberry Pi 4:

root@dcbff32:~# balena-engine run -it resin/resinos:2020.04.0.dev-raspberrypi4-64 /bin/bash
bash-4.4# cat /etc/issue
balenaOS 2.48.0 \n \l

bash-4.4# uname -a
Linux b77aeae18f84 4.19.75 #1 SMP PREEMPT Mon Mar 23 11:50:49 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux
root@dcbff32:~# balena-engine run -it resin/resinos:2020.04.0.dev-raspberry-pi /bin/bash
bash-4.4# cat /etc/issue
balenaOS 2.48.0 \n \l

bash-4.4# uname -a
Linux 8b0cf317a9c5 4.19.75 #1 SMP PREEMPT Mon Mar 23 11:50:49 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux

My Pi 4 was running a “standard” balenaOS installation (v2.48.0 development image), rather than Raspbian, and running balenaEngine rather than Docker. Therefore I was running balenaOS on balenaOS.

Furthermore I was able to successfully run the balenaos-in-container.sh script (balenaos-in-container project) on a RPi 4 with balenaOS (balenaOS on balenaOS):

On the balenaOS host OS:

$ cd /mnt/data
$ curl -LO https://github.com/balena-os/balenaos-in-container/archive/master.zip
$ unzip master.zip
$ cd balenaos-in-container-master
# Copied-and-pasted a config.json file downloaded from balenaCloud
$ vi config.json
# Edited "balenaos-in-container.sh" to replace "docker" with "balena-engine"
$ vi balenaos-in-container.sh
$ ./balenaos-in-container.sh
./balenaos-in-container.sh --image resin/resinos:2020.04.0.dev-raspberrypi4-64 --id test -c "$PWD/config.json" --detach
INFO: Creating balena-boot-test docker volume...
INFO: Creating balena-state-test docker volume...
INFO: Creating balena-data-test docker volume...
INFO: Running balenaOS as container balena-container-test ...
WARNING: Localhost DNS setting (--dns=127.0.0.2) may fail in containers.
40ad03481283b609a0b6df2d4f9c33f54051e008f186a681628793fdf0c7a321
INFO: balenaOS container running as balena-container-test

$ balena-engine ps -a
CONTAINER ID        IMAGE                                         COMMAND                  CREATED             STATUS                      PORTS               NAMES
40ad03481283        resin/resinos:2020.04.0.dev-raspberrypi4-64   "sh -c '/aufs2overla…"   18 seconds ago      Up 16 seconds                                   balena-container-test

$ balena-engine exec -it balena-container-test /bin/bash
bash-4.4# cat /etc/issue
balenaOS 2.48.0 \n \l

Anyway, try the Pi 4 image instead of the Pi 1 / Zero image. It is not clear that this was the problem you were having and it may still not work, but at least it would be a better match for the RPi 4.

Another note: Raspbian is a 32-bit OS, right? In which case, maybe, the RPi 3 (32 bits) image might be more suitable. Try the RPi 3 (32 bits) and the RPi 4 (64 bits) images – either sounds more promising than the RPi 1 / Zero image.