0

I would like to make a smoke test of a Raspberry Pi image in a docker container.

I am building the image using packer.io and the build-arm-image plugin in a gitlab pipeline inside a docker container. This packer plugin use qemu to run an existing arm image, run command inside it and save the resulting image.

I have tried to reload the image generated, but when trying to check if the systemd services which I had enabled were available, I got an error that systemd could not run in docker containers (something about dbus not being available)

Is there another way to run this image in a docker container (to be run in my pipeline) and test if the services are running and if the website/api is available?

9
  • "I would like to make a smoke test of a Raspberry Pi image in a docker container" -> I presume you understand you can't do that on a non ARM system; if so you should make it clear you are testing the image on a pi. If not: Docker does not emulate hardware, so your image must be compiled for the same platform as the host.
    – goldilocks
    Aug 11 '21 at 14:21
  • The goal with docker is quite opposite what you envision. Virtualization (VMware, HyperV, QUEMU and so on) is what you aim for so check out ESXi for Raspberry Pi, raspberrypi.org/blog/get-vmware-on-raspberry-pi
    – MatsK
    Aug 11 '21 at 20:09
  • What I have been doing was to use packer.io in docker. Packer (with the build-arm-image provisioner) run an arm image using qemu (will update question for clarification) This is how I am building an arm image in a docker container, but I fail to understand why the same trick does not work to run systemd...
    – Oneira
    Aug 12 '21 at 11:58
  • @goldilocks the elements I would like to test are not linked to the hardware. Those are more software components (script running every n minutes deleting files for example). I am not sure if some Systemd services are hardware dependent making all of it disabled in qemu...
    – Oneira
    Aug 12 '21 at 12:46
  • Unless you are making use of peripherals like the I2C bus or the camera, etc. you should be able to run an image in qemu. Which, WRT "is there another way", why don't you just run the image w/o docker. ie., just use qemu?
    – goldilocks
    Aug 12 '21 at 15:00
1

The goal with docker is quite opposite what you envision.

From https://www.redhat.com/en/topics/containers/containers-vs-vms

  • Containers are typically measured by the megabyte. They don’t package anything bigger than an app and all the files necessary to run, and are often used to package single functions that perform specific tasks (known as a microservice). The lightweight nature of containers—and their shared operating system (OS)—makes them very easy to move across multiple environments.

  • VMs are typically measured by the gigabyte. They usually contain their own OS, allowing them to perform multiple resource-intensive functions at once. The increased resources available to VMs allow them to abstract, split, duplicate, and emulate entire servers, OSs, desktops, databases, and networks.

So virtualization (VMware, HyperV, QUEMU and so on) is what you aim for so check out ESXi for Raspberry Pi, https://www.raspberrypi.org/blog/get-vmware-on-raspberry-pi/ that could be what you look for.

3
  • 1
    Note that while it is not the norm with docker, a container can contain an entire OS and be used much the same as a system in a true VM. "Entire" except for the kernel, because all containers run on the host kernel (which is why by implication they all must target the same platform). I mention this in case there is any confusion on the part of the OP ("Oh but I did use a complete system image..." -- no, not quite).
    – goldilocks
    Aug 11 '21 at 20:23
  • I agree kind of @goldilocks, An analogue is, you can use a spade to cut a cake with, but the goal for a spade is to dig dirt ;-)
    – MatsK
    Aug 11 '21 at 20:28
  • @MatsK thanks for your answer. As I have now corrected in the question, I am using qemu (in packer) in docker. What I not understand is how much of the kernel of the system running on qemu is shared with the other layers (docker, host)...
    – Oneira
    Aug 12 '21 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.