Ælex Ælex - 2 months ago 20
Linux Question

creating a docker container from a rootfs

I am dealing with the following issue:

A robot has an old Gentoo OS:

Linux bob 2.6.33.9-rt31-aldebaran-rt #1 SMP PREEMPT RT Thu Aug 27 21:42:34 CEST 2015


The problem:


  1. I am trying to build a toolchain for this robot, so that I can compile new apps using gcc/g++ 4.9 or later.

  2. The robot doesn't support this and there is limited space.

  3. I tried setting RPATH to copy newer library versions but there is simply too many problems involved, it didn't work and the only solution was static linking.

  4. It seems to me that I need to build apps by creating a rootfs from the robot.



So I
rsync'ed
the entire robot OS to my computer.
Now I want to build a docker image, so that I can use it to build gcc/g++ from scratch without the Robot's limitations (it has an
Intel(R) Atom(TM) CPU Z530 @ 1.60GHz
, 1Gb of RAM and only 29Mb of hard disk available).


  • I copied with rsync and kept all attributes, ownership and such.

  • The rootfs is at
    /home/alex/roots

  • I know that I need to run as root
    docker -t someorg/somename /home/alexrootfs



My questions are (treat me as a noob to docker):


  • I need to run under a i686 OS/KVM since that is what the robot OS runs under?

  • I need to set some specifics in a
    Dockerfile
    inside the rootfs (e.g.
    /home/alex/rootfs/Dockerfile



Are there any other hints, tips or issues from somebody who has done this before?
I want to use docker and not chroot since this eventually should be part of an automated tool for building apps for the robot but built on other machines.

Many thanks in advance!

Answer

You will need to run docker on the same architecture as the robot, yes.

If you already have a full rootfs, the Dockerfile would look something like this:

FROM scratch
ADD . /

and you would build using

docker -t someorg/somename /home/alex/rootfs/