Building and publishing to Docker Hub

I have a project at https://github.com/beruic/http-debug-server, which is built and published on Docker Hub at https://hub.docker.com/r/beruic/http-debug-server.

It builds automatically on Docker Hub for x86_64, but I would really like if I could have ARM images built automatically (either on Docker Hub or a Raspberry Pi I setup to do it), and have them published to Docker Hub too.

Does the Balena toolchain contain something I can use for this, or should I look somewhere else entirely?

Hi @beruic, have you seen our blog post on the subject? https://www.balena.io/blog/building-arm-containers-on-any-x86-machine-even-dockerhub/

@beruic,

You can use balena-cli to build an image for arm architecture using emulation via qemu.

https://www.balena.io/docs/reference/cli/#build-source

And to add to Chris’ message about the use of QEMU on x86: QEMU is a great “Plan A” option, but it is also known for fail in a small fraction of image build tasks (I think when executables make use of some unusual processor instructions). I’ve noticed that you were already anticipating the possibility of using a Raspberry Pi setup to automate the building of ARM images. Yes indeed, it can be a good “Plan B”. Just to share some handy building blocks, here’s how you would build an image on a Raspberry Pi, then copy the image from the balena-engine daemon on the Pi to a docker daemon running on your laptop or desktop:

# build the docker image on the RPi at the given IP address
balena build -a my_app -h 192.168.2.3 -p 2375 .
# copy the docker image from the device to the laptop/desktop
ssh root@192.168.2.3 -p 22222 balena-engine save my_image | docker load

Where the balena command above is the balena CLI, which would you execute on your laptop or desktop (or cloud server + VPN, if it starts getting really fancy…) :slight_smile:

The commands above assume that the RPi is running a development image of balenaOS, so port 2375 is exposed and root login is permitted. This is of course only appropriate in a protected private environment (local network), or behind a VPN.

After the image was copied from the RPi to you dev machine, you can proceed with uploading it to the Docker Hub. (Or I suppose you could also run a script on the RPi itself to upload the image directly to Docker Hub – a number of options to choose from!)

1 Like