Images built using `--emulated` option not working for Jetson Nano

Hello,

I’m running a Jetson Nano app on my openBalena server (latest version). I’m trying to deploy a simple app to the device that is built on my Ubuntu host (balena-cli v12.2.0).

Even after using --emulated option with balena deploy, my container is throwing [dashboard] standard_init_linux.go:207: exec user process caused "exec format error"

Deploy command: balena deploy jetson-app --build --source-dir . -e

My Dockerfile

FROM nginx:alpine

COPY [“index.html”, “data.js”, “style.css”, “/usr/share/nginx/html/”]
COPY ./nginx.conf /etc/nginx/conf.d/default.conf

Am I missing something?

That error possibly indicates that a binary for the wrong architecture is used, but it could be something else as well. Can you please paste the output of the balena deploy command so that we can compare it with what I get locally on my Arch host?

[Info]    No "docker-compose.yml" file found at "/test/nano-nginx"
[Info]    Creating default composition with source: "/test/nano-nginx"
[Info]    Building for aarch64/jetson-nano
[Build]   Building services...
[Build]   main Preparing...
[Info]    Installing qemu for aarch64 emulation...
[Info]    Emulation is enabled
[Build]   main Step 1/2 : FROM nginx:alpine
[Build]   main  ---> 6f715d38cfe0
[Build]   main Step 2/2 : COPY [".balena/qemu-execve","/tmp/qemu-execve"]
[Build]   main  ---> cad8acf3af80
[Build]   main Successfully built cad8acf3af80
[Build]   main Successfully tagged nano-nginx_main:latest
[Build]   main Waiting...
[Build]   Built 1 service in 0:18
[Info]    Creating release...
[Info]    Pushing images to registry...
[Info]    Saving release...
[Success] Deploy succeeded!
[Success] Release: 4d133148271b006fa27f339b99022647

This is what mine looks like

[Debug] Creating project…
[Info] Building for aarch64/jetson-nano
[Build] Building services…
[Build] dashboard Preparing…
[Info] Emulation is enabled
[Debug] Found build tasks:
[Debug] dashboard: build [./dockers/dashboard]
[Debug] Resolving services with [jetson-nano|aarch64]
[Debug] Found project types:
[Debug] dashboard: Standard Dockerfile
[Debug] Prepared tasks; building…
[Build] dashboard Step 1/4 : FROM nginx:alpine
[Build] dashboard —> ecd67fe340f9
[Build] dashboard Step 2/4 : COPY [".balena/qemu-execve","/tmp/qemu-execve"]
[Build] dashboard —> Using cache
[Build] dashboard —> 1a4ca371ca9b
[Build] dashboard Step 3/4 : COPY [“index.html”,“data.js”,“style.css”,"/usr/share/nginx/html/"]
[Build] dashboard —> Using cache
[Build] dashboard —> c23c14f7b63f
[Build] dashboard Step 4/4 : COPY ["./nginx.conf","/etc/nginx/conf.d/default.conf"]
[Build] dashboard —> 3089fa43c3bd
[Build] dashboard Successfully built 3089fa43c3bd
[Build] dashboard Successfully tagged jetson-nano-vision_dashboard:latest
[Build] dashboard Waiting…
[Build] Built 1 service in 0 seconds
[Info] Creating release…
[Debug] Tagging images…
[Debug] Authorizing push…
[Debug] Requesting access to previously pushed image repo (v2/a74608c4651257a50a8d326f110f3b07)
[Info] Pushing images to registry…
[Debug] Saving image registry.open-balena-mg.local/v2/669cf4bd4b22abbe36af91f2871e53b2
[Debug] Untagging images…
[Info] Saving release…
[Success] Deploy succeeded!
[Success] Release: f8e5a53bdd6001d824c602805778a2eb

Hi @abmg – thanks for the additional info. I was able to duplicate your problems when deploying to my Jetson Nano, using your Dockerfile. I think what’s happening here is that the image is being built using an incorrect architecture; if I add the file utility to the nginx:alpine container, I can see that:

  • when I run balena deploy locally, the nginx binary is for x86_64 (my laptop’s architecture); on my Nano, I see the exec format error you saw;
  • but when I run balena push, which uses the balena Cloud builders, the binary is for ARM aarch64 architecture, and on the Nano everything is fine.

I was able to get around this by using https://hub.docker.com/r/arm64v8/nginx, which is an official Docker build of nginx for 64-bit ARM:

  • FROM arm64v8/nginx as the first line of the Dockerfile
  • balena deploy JetsonNanoApp --emulated --build as the command

A quick search turned up this issue and this forum post, which offer a good background on what’s going on here.

One thing I’m not sure about is whether the balena CLI should be fetching the correct image when using nginx:alpine; I will check with a colleague of mine and get back to you. In the meantime, can you give this workaround a try and let us know if it works for you?

All the best,
Hugh

Hi there – I’ve checked with my colleague, and for now the CLI does require you to specify the architecture when running balena deploy. There are two issues tracking this, which I invite you to subscribe to:

One alternative to choosing the arm64v8/nginx image is to look for the sha256 digest of the image for the desired architecture, and use that in the Dockerfile. You can find these on the Dockerhub image page (https://hub.docker.com/_/nginx?tab=tags) under Tags -> Image, then click on the digest for your architecture. You should end up at a page like this one, and see the sha256 sum. You can then use it in your Dockerfile like so:

FROM nginx:alpine@sha256:8d99a3e08d0f07ca0fdf1db5c56b1f30d9cc97af5458ecfac604b8887cba289a

Please give that a try and let us know if you run into any problems.

All the best,
Hugh

Thanks for the suggestion, Hugh.

This’ll be a great feature. Hopefully it’ll be added soon