Creating an Arch Linux (ARMv7) Docker Image
This post describes how to create a Docker image for a Raspberry Pi (2/3) based on Arch Linux (ARMv7hf). The example includes Mono but could be adapted as required.
Creating a Base Image
A base Arch Linux (Armv7hf) can be created from the following command. The command creates an untagged image from piped input and STDIN.
curl -L http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz | gunzip | sudo docker import -
The image should be visible using the following command
This will return something along the lines of the following. The untagged image can be seen at the top of the list.
REPOSITORY TAG IMAGE ID CREATED SIZE <none> <none> ad615f58544f 1 minutes ago 686MB easypi/alpine-arm <none> fe637de3f099 4 months ago 5.78MB alexellis2/nginx-arm <none> f602e1a412d0 17 months ago 109MB
The image can then be tagged as appropriate e.g.
docker tag ad615f58544f arch-armv7hf-base
This can then be used in a Docker file as shown below.
Building a Working Image
The Docker file used was as follows.
FROM arch-armv7hf-base MAINTAINER John Newcombe ENV REFRESHED_AT 2017-10-28 RUN pacman -Suy --noconfirm RUN pacman -S --noconfirm mono RUN mkdir /opt/gaf
Note: The command to create the folder /opt/gaf was added in this example as it will be used as a bind point later on.
Build the image with the command
docker build --tag="johnnewcombe/arch-armv7hf" .
Testing the Image
Run the image with the following command
docker run -it --name myContainer johnnewcombe/arch-armv7hf bash
This should give you a bash shell within the container. To check the version of mono the following command can be used
This should return something like the following
Mono JIT compiler version 5.0.0 (Stable 188.8.131.52/9667aa6 Wed Jul 12 18:27:31 UTC 2017) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: __thread SIGSEGV: normal Notifications: epoll Architecture: armel,vfp+hard Disabled: none Misc: softdebug LLVM: supported, not enabled. GC: sgen (concurrent by default)
To push this up to the Docker Hub, use the following commands entering your password when requested.
docker login --username=<USERNAME> docker push johnnewcombe/arch-armv7hf