How do I make a container image from an SD card image?

40 views Asked by At

I develop for an embedded device and I would like to emulate this device in a docker container with the purpose to automate upgrade testing. The device contains the bootloader (u-boot), two root partitions and a data partition. During the upgrade process any partition may be touched. I have old SD card images we use in manufacturing that are copied to flash memory on the device. The image is a linux image built for an imx6 processor using yocto.

  1. Is it possible to make a container image from one of these images? If so how?
  2. Can a container image have multiple partitions? Or should I rethink this process?

I tried this FROM scratch ADD my_sd_card.img /

When I started the image I got Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "--attach": executable file not found in $PATH: unknown Error: failed to start containers: 3ff71505c5e9

1

There are 1 answers

1
larsks On

A container image is just a collection of files; it doesn't have partitions because it's not a block device. You could in theory unpack your .img file and make build a container image from that.

E.g:

  1. Mount the sd card image on a local directory

  2. Create a Dockerfile that looks like:

    FROM scratch
    COPY . .
    CMD ["/bin/sh"]
    
  3. Build the image:

    docker build -t myimage -f /path/to/Dockerfile /path/to/mountpoint
    

That might work; it depends on what is installed in the image and how it operates.