Santa Claus has brought a shiny new Raspberry 3B+ to my son for Christmas ! While it came with raspian by default, I didn’t want to change it to Mageia directly even if it’s now available. We wanted to use it as a prod environment for his docker based setup on his laptop. Which is using Mageia 6 and also Mageia containers. So that’s where the fun begins because there is no mageia docker image for armv7hl available and usable on Raspberry. Well, now at least I have one, locally and can document here the way to do it, if you want to reproduce, or you can use mine as well, thanks to the docker hub !
So here are the steps of what I did to obtain mine:
- Download the arm reference image for raspberry and uncompress it
- Mount it as a loopback mount to access its content
- Use the content and QEMU magic to run armv7hl binaries on your x86_64 machine and prepare your environment
- Build a chroot on this point containing the minimal set of packages for a Mageia distribution
- Create the Docker image out of that file and enjoy using it !
Which means wrt commands:
$ #1
$ cd $HOME/tmp
$ wget http://librepc.homelinux.org/dl/raspi/181217_mga7arm_rpi.img.xz
$ xz -d 181217_mga7arm_rpi.img.xz
$ #2
$ sudo kpartx -a 181217_mga7arm_rpi.img
$ sudo mkdir -p /mnt
$ sudo mount /dev/mapper/loop1p2 /mnt
$ #3
$ sudo urpmi qemu-user-static qemu-system-arm
$ sudo systemctl start systemd-binfmt
$ sudo chroot /mnt
# arch # isn't it magic !!
# urpmi.update -a
$ #4
# cd /home/pi
# export TARGETDIR=../tmp
# mkdir -p $TARGETDIR
# export MGAARCH=armv7hl
# export MGAVER=6
# /usr/sbin/urpmi.addmedia --distrib --urpmi-root "$TARGETDIR" ftp://ftp.free.fr/mirrors/mageia.org/distrib/$MGAVER/$MGAARCH
# LANG=C LANGUAGE=C /usr/sbin/urpmi --auto --no-recommends --download-all --allow-force --force --force-key --urpmi-root "$TARGETDIR" basesystem urpmi
# export TMPDM=/tmp
# echo 'NETWORKING=yes' > $TMPDM/network
# install -m 0644 $TMPDM/network "$TARGETDIR"/etc/sysconfig/network
# rm -f $TMPDM/network
# rm -rf "$TARGETDIR/dev" "$TARGETDIR/proc"
# install -m 0755 -d "$TARGETDIR/dev" "$TARGETDIR/proc"
# cat > $TMPDM/resolv.conf << EOF
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF
# install -m 0644 $TMPDM/resolv.conf "$TARGETDIR/etc/resolv.conf"
# rm -f $TMPDM/resolv.conf
# export DATE=2019-01-05
# cat > Dockerfile << EOF
FROM scratch
MAINTAINER bcornec@mageia.org
WORKDIR /
ADD mageia-$MGAVER-$MGAARCH-$DATE.tar.xz /
LABEL name="Mageia $MGAVER Base Image Arch: $MGAARCH" \
vendor="Mageia" \
license="GPLv2" \
build-date="$DATE"
CMD /bin/bash
EOF
# tar -C $TARGETDIR -cJf mageia-$MGAVER-$MGAARCH-$DATE.tar.xz .
# chmod 644 Dockerfile mageia-$MGAVER-$MGAARCH-$DATE.tar.xz
$ #5
$ ssh pi@raspberry mkdir docker
$ scp /mnt/home/pi/Dockerfile /mnt/home/pi/mageia-6-armv7hl-*.tar.xz pi@raspberry:docker
$ ssh pi@raspberry
pi$ sudo urpmi docker
pi$ cd docker
pi$ docker build -t mageiaofficial:6-armv7hl .
pi$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mageiaofficial 6-armv7hl 9b5880971b45 9 seconds ago 386 MB
pi$ docker run -ti mageiaofficial:6-armv7hl /bin/bash
[root@33a7bb3763b5 /]# urpmi tcsh
ftp://ftp.free.fr/mirrors/mageia.org/distrib/6/armv7hl/media/core/release/tcsh-6.19.00-5.mga6.armv7hl.rpm
installing tcsh-6.19.00-5.mga6.armv7hl.rpm from /var/cache/urpmi/rpms
Preparing... #############################################
1/1: tcsh #############################################
[root@33a7bb3763b5 /]# exit
Voilà !!
So now on your raspberry, it’s for you as simple as:
docker pull bcornec/mageia:6-armv7hl
Will soon provide a cauldron one as well 🙂